Answered EWS - Find last calendar modifications

  • Monday, April 30, 2012 5:42 AM
     
     

    Hello,

    I'm new user of EWS web services and could handled different functionnalities to make them work(FindItem, FindFolder,getItem, etc...) But I could not resolve this one:

    I try to find all latest modification or creation of appointments in a calendar folder. My first idea was to create a FindItemType request with restriction on LastModificationDate extended field( PropertyId = 0x3008) and call the findItem method. I've tryed the following code, but result is always empty ( aorit.Items == null):

     _esb = new ExchangeServiceBinding();
                _esb.Url = serviceUrl;
                _esb.Credentials = new NetworkCredential
                {                
                    UserName = userName,
                    Password = password,
                    Domain = domain
                };

    ...

                FindItemType fit = new FindItemType
                {
                    ItemShape = new ItemResponseShapeType
                    {
                        BaseShape = DefaultShapeNamesType.IdOnly
                    },
                    ParentFolderIds = folderTypes,
                    Traversal = ItemQueryTraversalType.Shallow,
                    Restriction = new RestrictionType
                    {
                        Item = new IsGreaterThanOrEqualToType
                        {
                            FieldURIOrConstant = new FieldURIOrConstantType
                            {
                                Item = new ConstantValueType { Value = lastModifiedDateSearched.ToUniversalTime().ToString("u") }
                            },
                            Item = new PathToExtendedFieldType
                            {
                                DistinguishedPropertySetIdSpecified = true,
                                DistinguishedPropertySetId = DistinguishedPropertySetType.Appointment,
                                PropertyType = MapiPropertyTypeType.SystemTime,
                                PropertyId = 0x3008,
                                PropertyIdSpecified = true,
                            }
                        }
                    }
                };

                FindItemResponseType response = _esb.FindItem(fit);

                List<ItemIdType> res = new List<ItemIdType>();
                foreach (FindItemResponseMessageType firmt in response.ResponseMessages.Items.Where(c => c.IsNotNull()))
                {
                    if (firmt.RootFolder.IsNotNull())
                    {
                        ArrayOfRealItemsType aorit = firmt.RootFolder.Item as ArrayOfRealItemsType;
                        if (aorit != null && aorit.Items.IsNotNull())
                        {
                            foreach (ItemType item in aorit.Items)
                            {
                                if (item.ItemId.IsNotNull())
                                {
                                    res.Add(item.ItemId);
                                }
                            }
                        }
                    }
                }

    Does anybody knows if my query seems correct? Do I use the right way to do this?

    Thank's for your help.


    • Edited by JCC74 Monday, April 30, 2012 6:04 AM
    •  

All Replies

  • Monday, April 30, 2012 4:41 PM
     
     

    should this DistinguishedPropertySetId = DistinguishedPropertySetType.Appointment become DistinguishedPropertySetId = DistinguishedPropertySetType.Calendar?

    You want to search on your calendar right?

    • Marked As Answer by JCC74 Tuesday, May 01, 2012 4:43 AM
    • Unmarked As Answer by JCC74 Tuesday, May 01, 2012 4:43 AM
    •  
  • Tuesday, May 01, 2012 4:46 AM
     
     

    Right, I'm searching in the calendar folder, but for appointments(worked in other functions).

    Anyway, I've tried with following values: Meeting, CalendarAssistant(no calendar value), Appointment -> still no error, and still no item returned.

  • Thursday, May 10, 2012 4:39 AM
     
     Answered

    Hi,

    After digging and digging, and... I finally found the problem. The PathToExtendedFieldType was not decleared correctly. Should have been simply:

                new PathToExtendedFieldType
                {
                    PropertyType = MapiPropertyTypeType.SystemTime,
                    PropertyTag = "0x3008"
                }

    If it can help!

    Bye.

    JC

    • Marked As Answer by JCC74 Thursday, May 10, 2012 4:39 AM
    •