EWS 2.0 - Initial Synchronization with MS Exchange Server 2019 and 2010 - Past Data Sync Problem

Ashish Vora 1 Reputation point
2020-12-28T13:33:06.973+00:00

Hi,

I'm using EWS API 2.0 version with Microsoft Exchange Server 2019 and 2010 SP2 (on-premise setup).

I have an application which subscribe 'WellKnownFolderName.Calendar' folder of email boxes using Streaming Notification. In the initial call, I send SyncState value to empty to get all the appointments from calendar for below event types.

EventType.Created, EventType.Modified, EventType.Moved, EventType.Deleted

With this setup, when I first time subscribe for a mailbox, it does not retrieve all the old data. That is, if I start my subscription today, it generally retrieves data onwards this month or last month (there is no exact range).

I need all the appointments available in mailbox, I’m not considering the archived one. At least the appointments those are currently present in mailbox need to be sync.

My questions:

  1. How much past data will come-up in the initial call ?
  2. Is there any range or limit ?
  3. Can I get past appointments, say after X date or from X to Y date?

I did lot of research on web, gone through MS documents, blogs and what not. I did not find a clue how much past data it will retrieve. Usually MS doc says it retrieves all appointment and suggest to use code like below, but it does not retrieve all appointment, and recommended code is already in place.

Here is my sample code:

private void SampleCode()
{
    var moreChangesAvailable = true;
    var syncState = string.Empty;

    while (moreChangesAvailable)
    {
        var changeCollection = exchangeService.SyncFolderItems(
            WellKnownFolderName.Calendar,
            PropertySet.IdOnly,
            null,
            10,
            SyncFolderItemsScope.NormalItems,
            syncState);

        // Internal method to process items retrieved from exchange
        ProcessCollection(changeCollection);

        syncState = changeCollection.SyncState;
        moreChangesAvailable = changeCollection.MoreChangesAvailable;
    }
}

Can someone please help with this ?

Please do the needful.
Thanks in advance.

Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
508 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,350 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Glen Scales 4,431 Reputation points
    2021-07-07T23:56:47.847+00:00

    SyncFolderItems doesn't do a Calendar Expansion query so if you have recurring appointments these won't be expanded, you can use it to track when the Masters are modified for your 1,3 questions it not going to return a full list of appointments like a FindItems with a CalendarView would. It makes Calendar Sync logic unfortunately pretty complicated (they did some work in the Graph https://learn.microsoft.com/en-us/graph/delta-query-events?tabs=http to make thing easier but it seems your using OnPrem).

    The easiest sync logic is to use FindItem with a CalendarView for the time windows you want to sync and then use Streaming notifications to trigger a query anytime it detects a change in the Calendar (not the most efficient though but it reliable). Other things you can do is read the recurrence blob and do your own expansion logic

    0 comments No comments