I do replicate from EWS using .SyncFolderItems
. However, this does not include virtual items from recurring series. So I want in addition to render a calendar view for a specific range to get all those virtual items as well.
if I use
CalendarView cView = new CalendarView(start, end, 1000);
FindItemsResults<Appointment> findAppointmentResults = calendar.FindAppointments(cView);
does EWS returns all appointments in this range including the virtual appointments from recurring-series? Or do I have to go the hard way described here and enumerate manually to all items?
For those who will run into the same situation. I tried and already succeeded in render both types of appointments.
EWS API calendar view automatically renders a recurring series for you.
The interesting part is how to set a approach that make it possible to replicate and also update your database in case the series gets deleted.
SyncFolderItems
AppointmentType
(Single, ReccuringMaster, Occurrence, Exception) in your database. Id.UniqueId
for each appointment in your database Store cleanGlobalObjectId
as well! How to get it:
var cleanGlobalObjectId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Meeting, 0x23, MapiPropertyType.Binary); var psPropSet = new PropertySet(BasePropertySet.FirstClassProperties) { cleanGlobalObjectId }; object calIdVal; ewsAppointment.TryGetProperty(cleanGlobalObjectId, out calIdVal); var syncId = Convert.ToBase64String((byte[])calIdVal);
To delete all appointments in your database you can use syncId
you get in 3. to catch them all. Example: If the RecurringMaster
is deleted by user. Delete all rows that refers to it.
After you synchronized appointments you can render a view from for a specific range to replicate those virtual appointments into your database. Easiest approach imho is to remove all by syncId
and insert all again.
var calendar = CalendarFolder.Bind(service, new FolderId(WellKnownFolderName.Calendar, new Mailbox(informerAccountMailbox.Mailbox)), psPropSet); var cView = new CalendarView(DateTime.Now.AddDays(informerAccountMailbox.DaysBeforeNow*-1), DateTime.Now.AddDays(informerAccountMailbox.DaysFromNow), 1000); var appointments = calendar.FindAppointments(cView);
Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.