none
EWS managed API ExchangeService.SyncFolderItems method and ignoredItemIds RRS feed

  • Question

  • Hi All,

    I have got the synchronizing of folder contacts working. It seems like the the API is not utilizing the ignore list I pass to the API. I am running in a windows service, and the synchronize function is called occassionally. We keep track of the changes that have already been processed. So  the idea is to capture all recent changes from the last call to the synchronization API. However, it looks like the ignore list is not working, because I get the same list of contact ID's every call. Somehow, I do not thnk I am using the API correctly. This is a little code snippet of my code.

    // Class member variables
    protected List<ItemId> _ignoreCollection = new List<ItemId>();
    protected Dictionary<string, ItemId> _dict = new Dictionary<string, ItemId>();
    .
    .
    .
    // Member function called every 20 minutes 
    bool isEndOfChanges = false;
    string sSyncState = null;
    do
    {
        // Get a list of changes (up to a maximum of 5) that have occurred on normal items in the folder since the prior synchronization.
    
        ChangeCollection<ItemChange> icc = _service.SyncFolderItems(
            fldr, // The ID of the folder that contains the items to be synchronized.
            PropertySet.FirstClassProperties, // PropertySet.IdOnly will return only the ID for efficiency
            _ignoreCollection, // The optional list of item Ids that should be ignored. IEnumerable < ItemId > ignoredItemIds
            10, // The maximum number of changes that should be returned.
            5, 
            SyncFolderItemsScope.NormalItems, 
            sSyncState
        );
    
        if (icc.Count == 0)
        {
            //Console.WriteLine("There are no item changes to synchronize.");
        }
        else
        {
            // Call delegates
            itemsChangedDelegate(icc);
            
            foreach (var ic in icc)
            {
    
                ItemId tmp;
                if (!_dict.TryGetValue(ic.ItemId.UniqueId, out tmp))
                {
                    _ignoreCollection.Add(ic.ItemId);
                    _dict[ic.ItemId.UniqueId] = tmp;
    
                }
            }
        }
    
        // Save the sync state for use in future SyncFolderHierarchy calls.
        sSyncState = icc.SyncState;
    
        if (!icc.MoreChangesAvailable)
        {
            isEndOfChanges = true;
        }
    
        token.ThrowIfCancellationRequested();
    
    } while (!isEndOfChanges);
    
    

    Any suggestions, or more documentation regarding the ignore list would be appreciated.

    Thanks,

    Tom

    Friday, December 15, 2017 6:19 PM

All replies

  • Hi All,

    I figured out what the issue was with the API. I changed the propertySet parameter from PropertySet.FirstClassProperties to PropertySet.IdOnly and all of a sudden everything started working as expected. So it seems the documentation should say the ignore list parameter is only looked at when we only return the chaned ItemId.

    Monday, December 18, 2017 6:09 PM