synic
synic

Reputation: 26678

EWS - Given an Appointment, get the owner's copy of the Appointment

Given an Appointment in EWS, is it possible to get the owner's copy?

For instance, if I am logged in as user1, I have user1's copy of an Appointment that was created by user2, I have impersonation rights, and I want to edit user2's copy of the Appointment, how can I obtain user2's copy?

Upvotes: 2

Views: 1165

Answers (1)

Glen Scales
Glen Scales

Reputation: 22032

You can use the PidLidCleanGlobalObjectId https://msdn.microsoft.com/en-us/library/office/cc839502.aspx which will be set on both the Meeting invitation/update and the Appointment object to search for the Meeting in an Attendee or Orgainizer mailbox eg

Appointment newAppointment = new Appointment(service);
newAppointment.Subject = "Test Subject";        
newAppointment.Start = new DateTime(2016, 08, 27, 17, 00, 0);
newAppointment.StartTimeZone = TimeZoneInfo.Local;
newAppointment.EndTimeZone = TimeZoneInfo.Local;
newAppointment.End = newAppointment.Start.AddMinutes(30);
newAppointment.Save();
newAppointment.Body = new MessageBody(Microsoft.Exchange.WebServices.Data.BodyType.Text, "test");
newAppointment.RequiredAttendees.Add("[email protected]");
newAppointment.Update(ConflictResolutionMode.AlwaysOverwrite ,SendInvitationsOrCancellationsMode.SendOnlyToAll);
ExtendedPropertyDefinition CleanGlobalObjectId = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Meeting, 0x23, MapiPropertyType.Binary);
PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties);
psPropSet.Add(CleanGlobalObjectId);
newAppointment.Load(psPropSet);
object CalIdVal = null;
newAppointment.TryGetProperty(CleanGlobalObjectId, out CalIdVal);
Folder AtndCalendar = Folder.Bind(service, new FolderId(WellKnownFolderName.Calendar,"[email protected]"));
SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(CleanGlobalObjectId, Convert.ToBase64String((Byte[])CalIdVal));
ItemView ivItemView = new ItemView(1);
FindItemsResults<Item> fiResults = AtndCalendar.FindItems(sfSearchFilter, ivItemView);
if (fiResults.Items.Count > 0) {
    //do whatever
}

Upvotes: 4

Related Questions