none
syncfolderItems is not giving up to date sync state for deleteditem folder RRS feed

  • Question

  • Hi,

    I am trying to get the up to date syncsate of deltined item folder of a mailbox and its being filtered on the basis of a specific time.

    here is my code

    ry
                        {
                            //Get a list of changes(up to MAX_CHANGES) that have occurred on normal items in the Inbox folder since the prior synchronization.
                          List<ItemId> itmid = new List<ItemId>();
                            if (syncStateObject.syncState == null)
                            {
                                DateTime startDate = DateTime.Now.AddYears(-2); //start from two years earlier
                                DateTime endDate = DateTime.Now.AddDays(-1);
                                var itemView = new ItemView(500, 0);
                                itemView.PropertySet = new PropertySet(BasePropertySet.IdOnly,
                                    ItemSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);
    
                                var filter = new SearchFilter.SearchFilterCollection(LogicalOperator.And,
                                    new SearchFilter.IsEqualTo(ItemSchema.ItemClass, "IPM.Appointment"),
                                    new SearchFilter.IsGreaterThanOrEqualTo(AppointmentSchema.Start, startDate),
                                    new SearchFilter.IsLessThan(AppointmentSchema.Start, endDate));
    
                                bool moreAvailable = true;
                                while (moreAvailable)
                                {
                                    FindItemsResults<Item> appointments = service.FindItems(getWellKnownFolderName(folder), filter, itemView);
                                    foreach (var item in appointments)
                                    {
                                        itmid.Add(item.Id);
    
                                    }
                                    itemView.Offset += itemView.PageSize;
                                    moreAvailable = appointments.MoreAvailable;
                                }
    
                            }
    
                            icc = service.SyncFolderItems(new FolderId(getWellKnownFolderName(folder), syncStateObject.siteMailBox), PropertySet.FirstClassProperties,
                                itmid.Count > 0 ? itmid : null , MAX_CHANGES, SyncFolderItemsScope.NormalItems, syncStateObject.syncState);

    Please note that firts time syncobject.syncSate will be null for first time

    now when i run above code for calendar folder it gives me the up to date sync state in one go, but for deleteditem folder it gets the list of itemid to be ignored, but it keep looping for long time. my mailbox is less than two year old so i am sure timespan i am giving is enough to get the list of all the ids.

    Can anybody point what i am doing wrong here?

    Thanks

    Thursday, November 24, 2016 5:21 PM

Answers

  •                         icc = service.SyncFolderItems(new FolderId(getWellKnownFolderName(folder), syncStateObject.siteMailBox), PropertySet.FirstClassProperties,
                                itmid.Count > 0 ? itmid : null , MAX_CHANGES, SyncFolderItemsScope.NormalItems, syncStateObject.syncState);

    This isn't going to help you try and debug what might be happening why don't you expand out your code and process the changes that being returned and look at the subject of at least some of the Items that SyncFolderItems is returning. That will give you much more detail as to what is being returned.

    Cheers
    Glen

    • Marked as answer by Nitrup Friday, November 25, 2016 10:16 AM
    Friday, November 25, 2016 4:41 AM

All replies

  •                         icc = service.SyncFolderItems(new FolderId(getWellKnownFolderName(folder), syncStateObject.siteMailBox), PropertySet.FirstClassProperties,
                                itmid.Count > 0 ? itmid : null , MAX_CHANGES, SyncFolderItemsScope.NormalItems, syncStateObject.syncState);

    This isn't going to help you try and debug what might be happening why don't you expand out your code and process the changes that being returned and look at the subject of at least some of the Items that SyncFolderItems is returning. That will give you much more detail as to what is being returned.

    Cheers
    Glen

    • Marked as answer by Nitrup Friday, November 25, 2016 10:16 AM
    Friday, November 25, 2016 4:41 AM
  • HI Glen,

    Thanks for pointing this out. Actually my filter condition was wrong for the item class. its sorted now.

    Thanks again

    Friday, November 25, 2016 10:16 AM