isEndOfChanges = <span style="color: #008000;">//<span style="color: #008000;"> Call SyncFolderItems repeatedly until no more changes are available.
<span style="color: #008000;">//<span style="color: #008000;"> sSyncState represents the sync state value that was returned in the prior synchronization response.
<span style="color: #0000ff;">do<span style="color: #000000;">
{
<span style="color: #008000;">//<span style="color: #008000;"> Get a list of changes (up to a maximum of 5) that have occurred on normal items in the In
Box folder since the prior synchronization.
ChangeCollection
icc = service.SyncFolderItems(<span style="color: #0000ff;">new FolderId(WellKnownFolderName.InBox),<span style="color: #800080;">5<span style="color: #000000;">,sSyncState);
</span><span style="color: #0000ff;">if</span> (icc.Count == <span style="color: #800080;">0</span><span style="color: #000000;">)
{
Console.WriteLine(</span><span style="color: #800000;">"</span><span style="color: #800000;">There are no item changes to synchronize.</span><span style="color: #800000;">"</span><span style="color: #000000;">);
}
</span><span style="color: #0000ff;">else</span><span style="color: #000000;">
{
</span><span style="color: #0000ff;">foreach</span> (ItemChange ic <span style="color: #0000ff;">in</span><span style="color: #000000;"> icc)
{
</span><span style="color: #0000ff;">if</span> (ic.ChangeType ==<span style="color: #000000;"> ChangeType.Create)
{
</span><span style="color: #008000;">//</span><span style="color: #008000;">TODO: Create item on the client.</span>
<span style="color: #000000;"> }
<span style="color: #0000ff;">else <span style="color: #0000ff;">if (ic.ChangeType ==<span style="color: #000000;"> ChangeType.Update)
{
<span style="color: #008000;">//<span style="color: #008000;">TODO: Update item on the client.
<span style="color: #000000;"> }
<span style="color: #0000ff;">else <span style="color: #0000ff;">if (ic.ChangeType ==<span style="color: #000000;"> ChangeType.Delete)
{
<span style="color: #008000;">//<span style="color: #008000;">TODO: Delete item on the client.
<span style="color: #000000;"> }
<span style="color: #0000ff;">else <span style="color: #0000ff;">if (ic.ChangeType ==<span style="color: #000000;"> ChangeType.ReadFlagChange)
{
<span style="color: #008000;">//<span style="color: #008000;">TODO: Update the item's read flag on the client.
<span style="color: #000000;"> }
Console.WriteLine(</span><span style="color: #800000;">"</span><span style="color: #800000;">ChangeType: </span><span style="color: #800000;">"</span> +<span style="color: #000000;"> ic.ChangeType.ToString());
Console.WriteLine(</span><span style="color: #800000;">"</span><span style="color: #800000;">ItemId: </span><span style="color: #800000;">"</span> +<span style="color: #000000;"> ic.ItemId.UniqueId);
</span><span style="color: #0000ff;">if</span> (ic.Item != <span style="color: #0000ff;">null</span><span style="color: #000000;">)
{
Console.WriteLine(</span><span style="color: #800000;">"</span><span style="color: #800000;">Subject: </span><span style="color: #800000;">"</span> +<span style="color: #000000;"> ic.Item.Subject);
}
Console.WriteLine(</span><span style="color: #800000;">"</span><span style="color: #800000;">===========</span><span style="color: #800000;">"</span><span style="color: #000000;">);
}
}
</span><span style="color: #008000;">//</span><span style="color: #008000;"> Save the sync state for use in future SyncFolderHierarchy calls.</span>
sSyncState =<span style="color: #000000;"> icc.SyncState;
</span><span style="color: #0000ff;">if</span> (!<span style="color: #000000;">icc.MoreChangesAvailable)
{
isEndOfChanges </span>= <span style="color: #0000ff;">true</span><span style="color: #000000;">;
}
} <span style="color: #0000ff;">while (!isEndOfChanges);