Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EWS : Appoitnment Item.Id.UniqueId is not constant

There is a weird problem I'm facing when working with EWS Managed API 2.0 with Exchange Server 2007 SP3.

When I create an appointment and I save it, I get its ID using the following code :

appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);

appointment.Id.UniqueId;

and I store it in my local DB so I can later use it to update the meeting or cancel it.

Later when I want to retrieve the conflicting meetings I use the following code :

CalendarView view = new CalendarView(Start, End);
view.PropertySet = new PropertySet();
Folder rootfolder = Folder.Bind(service, WellKnownFolderName.Calendar);
//view.PropertySet.Add(AppointmentSchema.Resources);
view.PropertySet.Add(ItemSchema.Id);
view.PropertySet.Add(AppointmentSchema.Subject);
view.PropertySet.Add(AppointmentSchema.Start);
view.PropertySet.Add(AppointmentSchema.Duration);
view.PropertySet.Add(AppointmentSchema.End);
view.PropertySet.Add(AppointmentSchema.Organizer);
view.PropertySet.Add(AppointmentSchema.Id);
Mailbox mailbox = new Mailbox(Email);
FolderId id = new FolderId(WellKnownFolderName.Calendar, mailbox);
CalendarFolder folder = CalendarFolder.Bind(service, id);
FindItemsResults<Appointment> findResults = folder.FindAppointments(view);

//Iterating through the conflicting meetings returned by folder.FindAppointments
foreach (Appointment app in findResults.Items)
  {
     appts.Rows.Add(app.Subject, app.Start, app.End, app.Duration, app.Id.UniqueId);
  }

and when I want to access the ID of one of the conflicting meetings I find it different than the ID I have it in my local DB although all other information are the same. I still can use my ID to bind to the appointment, but the problem is that the same meeting now have 2 different IDs. Why EWS isn't storing a unique ID for appointments why and (appointment.Id.UniqueId)is not constant ?

I didn't find a clear solution for this problem.

like image 461
Morano88 Avatar asked Jun 05 '13 08:06

Morano88


2 Answers

Appointment itself doesn't have unique id which doesnt change, but appointment has property ICalUid (i think its Unique calendar item id):

appointment.ICalUid;

which is really unique and doesn't change then meeting is updated as far as i tested.. i generated 1000 meetings for one person and all ICalUid's were unique. Try it, it helped for me :)

like image 99
Erikas Avatar answered Nov 08 '22 18:11

Erikas


This is Actually a very common problem faced by those who are using the EWS Managed API.
For some reason (I do not know why) the Unique ID changes when the appointment is moved to another folder.
You can find your question and your answer in my post here:
Exchange web services: why is ItemId not constant? [continued]

like image 26
Ahmad ElMadi Avatar answered Nov 08 '22 18:11

Ahmad ElMadi