When you start working on the Caching Api and/or Sync DisconnectedResultsets, did you take a look at the MS Exchange 2007 API?

I like the idea of storing a "state" and compare it some time later.. Very useful for syncing a disconnected resultset or updating some cache (~ one-way-sync)

Here's a code snippet around the Webservice API (using a third-party wrapper).

                //Initial synscronization. It will retrieve all existing items from the specified folder 
                SyncItemsResponse response = service.SyncItems(StandardFolder.Inbox);

                //Keep synchronization state in order to use it in next synchronizations
                string state = response.State;

                ItemCollection allExistingItems = response.CreatedItems;

                Console.WriteLine("Wait until new messages arrive or create/mark read/delete messages in the Inbox folder and press ENTER");

                //Synchronize items again but now include the state parameter in order to find changes from last synchronization
                SyncItemsResponse newResponse = service.SyncItems(StandardFolder.Inbox, state);

                ItemCollection newItems = newResponse.CreatedItems;
                ItemIdCollection deletedItems = newResponse.DeletedItems;
                ItemCollection updatedItems = newResponse.UpdatedItems;
                ReadFlagChangeCollection readFlagChangedItems = newResponse.ReadFlagChangedItems;

                //Display new items
                for (int i = 0; i < newItems.Count; i++)
                    Console.WriteLine("New = " + newItems[i].Subject);
                    Console.WriteLine("New ItemId= " + newItems[i].ItemId);

                //Display deleted items
                for (int i = 0; i < deletedItems.Count; i++)
                    Console.WriteLine("Deleted ItemId = " + deletedItems[i]);

                //Display updated items
                for (int i = 0; i < updatedItems.Count; i++)
                    Console.WriteLine("Updated = " + updatedItems[i].Subject);
                    Console.WriteLine("Updated ItemId = " + updatedItems[i].ItemId);

                //Display items marked read/unread
                for (int i = 0; i < readFlagChangedItems.Count; i++)
                    Console.WriteLine("Marked read/unread = " + readFlagChangedItems[i].ItemId);
                    Console.WriteLine("IsRead = " + readFlagChangedItems[i].IsRead);

Thanks Marco

This thread was imported from our support forum. The original discussion may contain more detailed answer.

asked Apr 08 '10 at 20:59

Marco's gravatar image


One Answer:

Usage of such an API is possible, when:

  • Each transaction is logged (possible). There must be some sequential marker ordering all of them, it will act as state marker.

  • Changes made in a particular transaction are logged as well (e.g. as our OperationLog). So to repeat them @ another database, you must mainly send the log.


  • Identifiers must be the same at both storages

  • If you need sync scopes, it is pretty complex to extend this approach for this case. Easy, if each transaction may "touch" just one scope, but almost impossible in general

I hardly imagine why this technique is attractive for DisconnectedState - it isn't designed to host really large graphs, so it's much easier to simply refresh it. But it's pretty good for syncing between client (or several clients) and server.

answered Apr 08 '10 at 23:42

Alex%20Yakunin's gravatar image

Alex Yakunin

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview


Once you sign in you will be able to subscribe for any updates here



Asked: Apr 08 '10 at 20:59

Seen: 1,929 times

Last updated: Apr 08 '10 at 20:59

powered by OSQA