当前位置: 首页 > 知识库问答 >
问题:

Initial Exchange Web Services sync start on given time

贺懿轩
2023-03-14

We are doing Exchange web server synchronization with our application.To identify EWS changes we use;service.SyncFolderItems() method, like explain on MSDN.But, while doing initial sync it takes all the events in calendar, very older ones too.To avoid getting older events we need to use time period or Sync Start From time while requesting changes from SyncFolderItems() method.

1) Can SyncFolderItems() method accept user given time period when getting events from EWS ? & How ?
2) If not, Any workaround ?

共有1个答案

仲孙文乐
2023-03-14

There is a way to avoid older events in calendar using service.SyncFolderItems() method.

<SyncFolderItems>
 <ItemShape/>
 <SyncFolderId/>
 <SyncState/>
 <Ignore/>
 <MaxChangesReturned/>   <SyncScope/>
</SyncFolderItems>

That Ignore parameter will accept List of event Ids.and ignore them while syncing.To do that , First we need to retrieve older event IDs, Exchange will only accept two years old event

        DateTime startDate = DateTime.Now.AddYears(-2); //start from two years earlier
        DateTime endDate = DateTime.Now.AddMonths(-1); // End One Month before,
//you can use Convert.ToDateTime("01/01/2013"); what ever date you wanted.

Create Item id List;

List<ItemId> itmid = new List<ItemId>();

Create Calendar View object;

CalendarView cView = new CalendarView(startDate, endDate);

Retrieve Appointments;

 // Retrieve a collection of appointments by using the calendar view.
        FindItemsResults<Item> appointments = service.FindItems(WellKnownFolderName.Calendar, cView);
FindItemsResults<Appointment> appointments = service.FindAppointments(WellKnownFolderName.Calendar, cView);
foreach (var item in appointments)
        {
            itmid.Add(item.Id);

        }
service.SyncFolderItems(new FolderId(WellKnownFolderName.Calendar), PropertySet.IdOnly, itmid, 10, SyncFolderItemsScope.NormalItems, sSyncState);
 类似资料:

相关问答

相关文章

相关阅读