Why does EWS Managed API SyncFolderItems not return recurring appointments

你说的曾经没有我的故事 提交于 2019-12-10 16:48:48

问题


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?


回答1:


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.




回答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.




回答3:


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.



来源:https://stackoverflow.com/questions/6117353/why-does-ews-managed-api-syncfolderitems-not-return-recurring-appointments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!