none
Unique id on AppointmentItem, EWS Managed API 2.0 RRS feed

  • Question

  • Hi,

    We have previously used the EntryId on an AppointmentItem as a unique id when using the EWS service. However in the latest release of the managed API (2.0) this porperty do not exist.

    We are now trying to use the property Item.Id but this id do not seem to be unique.

    What I would like to know is; which Item property can be used as a unique identifier? Preferably globally because we are using servers on many different domains.

    Thanks,

    Nicklas

    Monday, January 14, 2013 9:22 PM

Answers

  • >>When testing I find that all occurrences of a recurring appointment has the same PidLidCleanGlobalObjectId:

    The first thing to understand is that's the normal behaviour with a recurring appointment in the Exchange Store you only have one underlying Store Item (The master instance). The recurrence is just a pattern property on that Master Item that the client expands and deleted instances and exception are stored as attachments on that Master instance (if you want to understand this have a look with MFCMapi). So when it comes to instances of recurring appointments there is no unique ID as such because there is no real underlying object (unless that instance is an exception or deleted instance).

    The Item.Id is unique and you can use to Bind to an Item but similar it can only be used to bind to Real Items (and would be the same on recurring instances). PR_Search_Key maybe what your looking for i would suggest having a read of http://msdn.microsoft.com/en-us/library/office/cc815908.aspx

    Cheers
    Glen

    Wednesday, January 16, 2013 5:50 AM

All replies

  • PidLidCleanGlobalObjectId http://msdn.microsoft.com/en-us/library/cc839502.aspx is the best property to use because its unique, global and can be used to find the instance of the appointment in an attendees mailboxes and also any meeting invitations etc. see http://blogs.msdn.com/b/mstehle/archive/2009/09/02/ews-uid-not-always-the-same-for-orphaned-instances-of-the-same-meeting.aspx. For an example of using it in the Managed API

                Appointment apt = new Appointment(service);
                apt.RequiredAttendees.Add("blah@som.co");
                apt.Start = DateTime.Now;
                apt.End = DateTime.Now.AddHours(1);
                DayOfTheWeek[] days = new DayOfTheWeek[] { DayOfTheWeek.Saturday };
                apt.Recurrence = new Recurrence.WeeklyPattern(apt.Start.Date, 1, days);
                apt.Recurrence.StartDate = apt.Start.Date;
                apt.Recurrence.NumberOfOccurrences = 10;
    
                apt.Save();
                object PropVal = null;
                ExtendedPropertyDefinition CleanGlobalObjectId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Meeting, 0x23, MapiPropertyType.Binary);
                PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties);
                psPropSet.Add(CleanGlobalObjectId);
                apt.Load(psPropSet);
                apt.TryGetProperty(CleanGlobalObjectId, out PropVal);
    Cheers
    Glen
    Tuesday, January 15, 2013 5:51 AM
  • Hi Glen,

    Thanks for the reply.

    All seems to be fine until I try it on an appointment which is recurring.

    When testing I find that all occurrences of a recurring appointment has the same PidLidCleanGlobalObjectId:

                var importStartSpan = DateTime.Now.AddDays(0);
                var importEndSpan = DateTime.Now.AddDays(100);
    
                var folderId = new FolderId(WellKnownFolderName.Calendar, new Mailbox("mail@domain.com"));
                var view = new CalendarView(importStartSpan, importEndSpan);
    
                var appointments = ews.FindAppointments(folderId, view);
    
                ExtendedPropertyDefinition CleanGlobalObjectId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Meeting, 0x23, MapiPropertyType.Binary);
                PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties);
                psPropSet.Add(CleanGlobalObjectId);
                ews.LoadPropertiesForItems(appointments, psPropSet);
    
                var globalObjectIds = new Dictionary<string, byte[]>();
    
                foreach (var item in appointments)
                {
                    byte[] PropVal = null;
                    item.TryGetProperty(CleanGlobalObjectId, out PropVal);
                    var str = GetStringFromHex(PropVal);
                    try
                    {
                        globalObjectIds.Add(str, PropVal);
                    }
                    catch (ArgumentException argException)
                    {
                        Assert.Fail("Unique ids are not unique. " + str + " Total items in dictionary: " + globalObjectIds.Count);
                    }
                }

    Is it possible to get all unique ids in all mailboxes on the given Exchange server?

    Thanks

    Tuesday, January 15, 2013 1:02 PM
  • >>When testing I find that all occurrences of a recurring appointment has the same PidLidCleanGlobalObjectId:

    The first thing to understand is that's the normal behaviour with a recurring appointment in the Exchange Store you only have one underlying Store Item (The master instance). The recurrence is just a pattern property on that Master Item that the client expands and deleted instances and exception are stored as attachments on that Master instance (if you want to understand this have a look with MFCMapi). So when it comes to instances of recurring appointments there is no unique ID as such because there is no real underlying object (unless that instance is an exception or deleted instance).

    The Item.Id is unique and you can use to Bind to an Item but similar it can only be used to bind to Real Items (and would be the same on recurring instances). PR_Search_Key maybe what your looking for i would suggest having a read of http://msdn.microsoft.com/en-us/library/office/cc815908.aspx

    Cheers
    Glen

    Wednesday, January 16, 2013 5:50 AM
  • Based on the your replies we are going to use the item.Id.UniqueId together with item.Start.Ticks as a unique identifier for an item.

    Thank you.

    BR

    Nicklas

    Thursday, January 17, 2013 8:25 AM