4

I'm using the managed API of EWS to synchronize a scheduling application with exchange calendars. I get all normal meetings fine, but I am not getting any repeating/recurring appointments.

My code follows:

itemChangeCollection = _service.SyncFolderItems(
                            new FolderId(WellKnownFolderName.Calendar,
                                         new Mailbox(Email)),
                            propertySet,
                            null,
                            Settings.Default.ExchangeSyncFetchCount,
                            SyncFolderItemsScope.NormalItems,
                            syncState);

What do I need to change to see the recurring appointments as well?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Charley Rathkopf
  • 4,720
  • 7
  • 38
  • 57

3 Answers3

3

Instances of recurring appointments are not "real" items in the store. They are virtual in the sense that they are calculated whenever you perform a search with a calendar view and a timeframe.

The only way to find recurring appointments is to use the FindItems method.

Henning Krause
  • 5,302
  • 3
  • 24
  • 37
  • Actually I'm using FindItem to retrieve appointments from a room calendar with start & end date restrictions and still not receiving recurring meetings. – Sergiu Indrie Oct 30 '17 at 10:13
  • I just realized the reason I wasn't receiving recurring meetings even though I was using FindItem, was that I was using a search filter (I wanted to use both item view for pagination and specify a date interval). If you want to receive recurring items you can't use a search filter (at least not one with date conditions). – Sergiu Indrie Jan 04 '18 at 06:47
2

SyncFolderItems only returns the necessary information to reconstruct a recurring serie but does not expand the individual occurrences. If you need expanded occurrences you need to use the FindItems method.

However, even assuming you can expand the recurrence yourself, SyncFolderItems alone does not provide all the necessary information.

SyncFolderItems will return a list of events with Single or RecurringMaster AppointmentType. A RecurringMaster event contains the ModifiedOccurrences and DeletedOccurrences properties. Unfortunately the items in ModifiedOccurrences only contains the ItemId, not the Item itself. It seems necessary to solve all exception separately to get the fields of modified occurrences. From the documentation:

Each OccurrenceInfo object in the ModifiedOccurrences collection contains four properties: End, ItemId, OriginalStart, and Start. To access additional properties on the exception item, you must bind to the item by using the OccurrenceInfo.ItemId.

foreach (OccurrenceInfo item in recurringMasterItem.ModifiedOccurrences)
{
   Appointment modifiedItem = Appointment.Bind(service, item.ItemId);
   Console.WriteLine("Subject: " + modifiedItem.Subject);
}

In other words, with the data you get from SyncFolderItem you can expand a recurrence, including time exceptions and deleted occurrences but you would have to resolve exceptions on other fields (ie. summary, body, location. etc) with additional .Bind() calls.

Marco Ancona
  • 2,073
  • 3
  • 22
  • 37
  • Marco, do you know how you could find out which of the ModifiedOccurrences have just been modified? (After carrying out a SyncFolderItems, and loading the ModifiedOccurrences property, it contains every occurrence that has ever been modified, rather than just the one that been modified since the last sync). Thanks! – Ted Jan 11 '18 at 15:12
0

SyncFolderItems will give you the recurring master items, but does not expand them into occurrences. The recurring master holds the common properties for all items, the recurring pattern and a list of exceptions and deletions. This is all the information required to expand them to occurrences. Although you are supposed to call Appointment.BindToOccurrence to bind the properties for an individual occurrence from a recurring master based on an occurrence index. The downside is this makes an EWS call for each occurrence.

tjmoore
  • 1,045
  • 1
  • 8
  • 19