Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exchange EWS Folder Syncing only picking up programmatic changes

Using this code I'm creating a proof of concept for syncing My Exchange (2007 SP1) driven outlook calendar syncable to other calendaring systems via the Exchange EWS Managed API.

    static void SyncAppointments()
    {
        ChangeCollection<ItemChange> changeCollection = service.SyncFolderItems(new FolderId(WellKnownFolderName.Calendar), PropertySet.FirstClassProperties, null, 512, SyncFolderItemsScope.NormalItems, syncState);

        Console.WriteLine("\n\n");
        Console.WriteLine("Changes");
        Console.WriteLine("============================\n");

        if (changeCollection.Count > 0) {
            foreach (ItemChange item in changeCollection)
            {
                Console.WriteLine("ChangeType: " + item.ChangeType.ToString());
                Console.WriteLine("ItemId: " + item.ItemId.UniqueId);
                Console.WriteLine("Subject: " + item.Item.Subject);
                Console.WriteLine("===========\n");
            }
        }
        else {
            Console.WriteLine("No changes to Sync.\n");
        }

        syncState = changeCollection.SyncState;
    }

This is working great for the most part, I get the default first set of changes (all items) and subsequently I get No changes to Sync.... now when I create an appointment via the EWS and then run the sync operation I get the expected result. A change item reflecting the creation of the appointment (and it appearing in outlook) appears.

Changes
============================

ChangeType: Create
ItemId: AAMkADRjYjE1NTVlLTk5ODktNGJiYS1hMTdjLTU2MzE5OGU5ZWNlOABGAAAAAADPxihYdsIG
TqRV5hKVbnQhBwASbprVW92zQZkfrIZIxiR2AEg2AOQDAAASbprVW92zQZkfrIZIxiR2AEg2KWYFAAA=

Subject: New Appointment
===========

Now if I add/cancel appointments via outlook the syncing operation does not pick up the changes.

Changes
============================

No changes to Sync.

Why is this?

like image 704
jondavidjohn Avatar asked Dec 01 '25 21:12

jondavidjohn


1 Answers

Are you checking MoreChangesAvailable? You could be losing them between calls if you have many changes (greater than maxChangesReturned).

You should write out the syncState to see what it contains. Make sure it is getting passed properly - it is essentially a hash of the last sync datetime.

like image 119
SliverNinja - MSFT Avatar answered Dec 03 '25 09:12

SliverNinja - MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!