EWS : Appoitnment Item.Id.UniqueId is not constant

2019-02-18 04:54发布

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.

3条回答
Animai°情兽
2楼-- · 2019-02-18 05:15

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 :)

查看更多
走好不送
3楼-- · 2019-02-18 05:16

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]

查看更多
Melony?
4楼-- · 2019-02-18 05:29

Keep in mind that Outlook recreates appointments when it processes incoming calendar updates.

查看更多
登录 后发表回答