none
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.

    Code:

                    

    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.PropertySet.Add(FolderSchema.DisplayName);
                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")
                    {
                        Console.WriteLine(f.Id);

                      //  GetSharedCalendarFolders(service, f.Id);

                        var calendar2 = CalendarFolder.Bind(service,
                                                           f.Id,
                                                           BasePropertySet.FirstClassProperties);
                        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)
                            {
                                Console.WriteLine(Appoint.Start);
                                Console.WriteLine(Appoint.Subject);
                            }
                        }
    }

    }

    Thanks


    Tuesday, July 11, 2017 2:08 PM

All replies

  • https://social.msdn.microsoft.com/Forums/office/en-US/home?category=officedev

    Maybe you should post to the office developer forum.

    Tuesday, July 11, 2017 8:00 PM