Hi All,
I hope someone can help me with an issue I've been facing while ending meetings on my calendar programmatically. I've tried out 2 cases, 1 of which works and 1 doesn't. The code block which carries out the operation is as follows (The Subject that I check for changes depending on the meeting I want to end, and the entire section is within a try-catch block).
target = Appointment.BindToRecurringMaster(service, result.Id, new PropertySet(AppointmentSchema.Organizer, AppointmentSchema.Subject, AppointmentSchema.Location, AppointmentSchema.Recurrence, AppointmentSchema.RequiredAttendees, AppointmentSchema.OptionalAttendees, AppointmentSchema.AppointmentType)); if (target.Subject.Equals("Testing Modified")) { target.Recurrence.EndDate = DateTime.Today; target.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToNone); }
Case 1: Ending a meeting in my calendar, where I am the organizer.
This proceeds without any error. All occurrences of the meeting from DateTime.Today onwards is removed from my calendar, and reflected in Outlook. It does remain on the calendars of other attendees, this is by design. The following is the request to set an EndDate and the corresponding response:
<Trace Tag="EwsRequest" Tid="1" Time="2013-08-28 07:27:05Z" Version="15.00.0516.014"><?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><t:RequestServerVersion Version="Exchange2010_SP2" /></soap:Header><soap:Body><m:UpdateItem ConflictResolution="AlwaysOverwrite" SendMeetingInvitationsOrCancellations="SendToNone"><m:ItemChanges><t:ItemChange><t:ItemId Id="AAMkADdiMzY1ZWMwLTRkY2YtNDhiNi05OWY3LTA1OTJlMWY1OGNjNQBGAAAAAADlthcp0nAmSJHp0KzsDecrBwAQPHeHSGwtR6J6/hI0H+gZAAAA/CwVAABtryIZ/QTbT6f5oUZQX9AxAAUvHYQyAAA=" ChangeKey="DwAAABQAAAASQRS5pRnpSpEuDS9HteUWAADkaA==" /><t:Updates><t:SetItemField><t:FieldURI FieldURI="calendar:Recurrence" /><t:CalendarItem><t:Recurrence><t:WeeklyRecurrence><t:Interval>1</t:Interval><t:DaysOfWeek>Tuesday</t:DaysOfWeek><t:FirstDayOfWeek>Sunday</t:FirstDayOfWeek></t:WeeklyRecurrence><t:EndDateRecurrence><t:StartDate>2013-08-27</t:StartDate><t:EndDate>2013-08-28+05:30</t:EndDate></t:EndDateRecurrence></t:Recurrence></t:CalendarItem></t:SetItemField></t:Updates></t:ItemChange></m:ItemChanges></m:UpdateItem></soap:Body></soap:Envelope></Trace><Trace Tag="EwsResponse" Tid="1" Time="2013-08-28 07:27:07Z" Version="15.00.0516.014"><?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="146" MinorBuildNumber="0" Version="Exchange2010_SP2" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><m:UpdateItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"><m:ResponseMessages><m:UpdateItemResponseMessage ResponseClass="Success"><m:ResponseCode>NoError</m:ResponseCode><m:Items><t:CalendarItem><t:ItemId Id="AAMkADdiMzY1ZWMwLTRkY2YtNDhiNi05OWY3LTA1OTJlMWY1OGNjNQBGAAAAAADlthcp0nAmSJHp0KzsDecrBwAQPHeHSGwtR6J6/hI0H+gZAAAA/CwVAABtryIZ/QTbT6f5oUZQX9AxAAUvHYQyAAA=" ChangeKey="DwAAABYAAAAQPHeHSGwtR6J6/hI0H+gZAAABAHiO" /></t:CalendarItem></m:Items><m:ConflictResults><t:Count>0</t:Count></m:ConflictResults></m:UpdateItemResponseMessage></m:ResponseMessages></m:UpdateItemResponse></s:Body></s:Envelope></Trace>
As you can see, no errors in the response.
Case 2: Ending a meeting in my calendar, where someone else is the organizer.
Same code, same everything (except the Subject to check for, of course), but it gives aServiceResponseException: Set action is invalid for property. (Where I'm assuming the property is Recurrence.EndDate). The following is the request to set an EndDate and the corresponding response:
<Trace Tag="EwsRequest" Tid="1" Time="2013-08-28 07:22:21Z" Version="15.00.0516.014"><?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><t:RequestServerVersion Version="Exchange2010_SP2" /></soap:Header><soap:Body><m:UpdateItem ConflictResolution="AlwaysOverwrite" SendMeetingInvitationsOrCancellations="SendToNone"><m:ItemChanges><t:ItemChange><t:ItemId Id="AAMkADdiMzY1ZWMwLTRkY2YtNDhiNi05OWY3LTA1OTJlMWY1OGNjNQBGAAAAAADlthcp0nAmSJHp0KzsDecrBwAQPHeHSGwtR6J6/hI0H+gZAAAA/CwVAABtryIZ/QTbT6f5oUZQX9AxAAUvHYQuAAA=" ChangeKey="DwAAABYAAAAQPHeHSGwtR6J6/hI0H+gZAAABAHf6" /><t:Updates><t:SetItemField><t:FieldURI FieldURI="calendar:Recurrence" /><t:CalendarItem><t:Recurrence><t:WeeklyRecurrence><t:Interval>1</t:Interval><t:DaysOfWeek>Monday</t:DaysOfWeek><t:FirstDayOfWeek>Sunday</t:FirstDayOfWeek></t:WeeklyRecurrence><t:EndDateRecurrence><t:StartDate>2013-08-26</t:StartDate><t:EndDate>2013-08-28+05:30</t:EndDate></t:EndDateRecurrence></t:Recurrence></t:CalendarItem></t:SetItemField></t:Updates></t:ItemChange></m:ItemChanges></m:UpdateItem></soap:Body></soap:Envelope></Trace><Trace Tag="EwsResponse" Tid="1" Time="2013-08-28 07:22:22Z" Version="15.00.0516.014"><?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><h:ServerVersionInfo MajorVersion="14" MinorVersion="3" MajorBuildNumber="146" MinorBuildNumber="0" Version="Exchange2010_SP2" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><m:UpdateItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"><m:ResponseMessages><m:UpdateItemResponseMessage ResponseClass="Error"><m:MessageText>Set action is invalid for property.</m:MessageText><m:ResponseCode>ErrorInvalidPropertySet</m:ResponseCode><m:DescriptiveLinkKey>0</m:DescriptiveLinkKey><m:MessageXml><t:FieldURI FieldURI="calendar:Recurrence" /></m:MessageXml><m:Items /></m:UpdateItemResponseMessage></m:ResponseMessages></m:UpdateItemResponse></s:Body></s:Envelope></Trace>
What could be the reason for this? I'm only making changes to objects in my calendar with my credentials, so permissions shouldn't be an issue - I don't even want changes reflecting on others' calendars. I was able to perform this operation using Outlook (changing the EndDate of a meeting in my calendar where someone else is the organizer), it worked as expected. I assume that everything that can be done using Outlook, can be done using EWS Managed API – please correct me if I’m wrong.
Here's another weird case - In case 2, instead of changing Recurrence.EndDate, I tried changing the Subject, and that works just fine! Again, the change in Subject is reflecting only on my calendar.
Please let me know any solutions or workarounds to this issue, as it seems to be very inconsistent behavior and is a dealbreaker.
Thanks,
Shashank