Access Events From Shared Calendar using Exchange Services in c# RRS feed

  • Question

  • Hi,

    I am using below code for accessing a Shared Calendar using EWS, but everytime I am getting count as zero for appointments. The Calendar has appointments in the last month which I am trying to retrieve. The Code works fine for my Calendar and retrieve events as well when I use "WellKnownFolderName.Calendar" in place of f.Id in the below line:

    CalendarFolder calendar = CalendarFolder.Bind(service,f.Id, new PropertySet());

    The complete code is below, not getting any exception in the code, the only issue is it is not retrieveing the events of past month when it has events in it. Please help me in this.



    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
                service.Credentials = new WebCredentials("user@domain.com", "password");   
                service.Url = new Uri("https://outlook.office365.com/ews/exchange.asmx");
     FolderView view = new FolderView(100);
                view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
                view.Traversal = FolderTraversal.Deep;
     FindFoldersResults findFolderResults = service.FindFolders(WellKnownFolderName.Root, view);
    foreach (Folder f in findFolderResults)
                    //show folderId of the folder

                    if (f.DisplayName == "user2@domain.com")

                      //  GetSharedCalendarFolders(service, f.Id);

                        var calendar2 = CalendarFolder.Bind(service,
                        DateTime StartDate = DateTime.Today.AddMonths(-1);
                        DateTime EndDate = DateTime.Today.AddMonths(1);
                        CalendarView cv = new CalendarView(StartDate, EndDate);
    FindItemsResults<Appointment> fapts = service.FindAppointments(f.Id, cv);

                        if (fapts.Items.Count > 0)
                            foreach (Appointment Appoint in fapts)



    Tuesday, July 11, 2017 1:46 PM

All replies

  • You should just be binding to the Calendar of the Shared Mailbox eg

    FolderId folderToAccess = new FolderId(WellKnownFolderName.Calendar, "sharedMailbox@domain.com");
    CalendarFolder calendar = CalendarFolder.Bind(service,FolderId);

    And then do a FindItem on the calendar folder you bind to.


    Thursday, July 13, 2017 2:30 AM