'C# create calendar item with EWS, how to get back the results?
I build an app based on this site http://msdn.microsoft.com/en-us/library/dd633661%28v=EXCHG.80%29.aspx
appointment.Subject = "Status Meeting";
appointment.Body = "The purpose of this meeting is to discuss status.";
appointment.Start = new DateTime(2009, 3, 1, 9, 0, 0);
appointment.End = appointment.Start.AddHours(2);
appointment.Location = "Conf Room";
appointment.RequiredAttendees.Add("[email protected]");
appointment.RequiredAttendees.Add("[email protected]");
appointment.OptionalAttendees.Add("[email protected]");
appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);
how I can return the XML results "... < t:ItemId Id="AAMkADk=" ChangeKey="DwAAAB" /> ..." so I can use it later to delete or edit the calendar item!?!
Microsoft made a god job with the whole Framework, but did they really forgot this little thing?
I found some (not logical for me) solution Link should I use this to solve the issue?
cheers
Solution 1:[1]
It looks like the solution you found is not returning the XMl results, persay. What the solution is doing is appending a unique identifier to the e-mail as an ExtendedPropertyDefinition. Then after sending it, the solution searches through the "Sent Items" folder to find a saved copy of the e-mail that was just sent by matching on the unique identifier that was appended before the e-mail was sent.
Then as written on the blog,
The following is the XML request that is generated by calling FindItems in the above code example.
<m:FindItem Traversal="Shallow">
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:Subject" />
<t:ExtendedFieldURI PropertySetId="20b5c09f-7cad-44c6-bdbf-8fcbeea08544" PropertyName="MyExtendedPropertyName" PropertyType="String" />
</t:AdditionalProperties>
</m:ItemShape>
<m:IndexedPageItemView MaxEntriesReturned="5" Offset="0" BasePoint="Beginning" />
<m:Restriction>
<t:IsEqualTo>
<t:ExtendedFieldURI PropertySetId="20b5c09f-7cad-44c6-bdbf-8fcbeea08544" PropertyName="MyExtendedPropertyName" PropertyType="String" />
<t:FieldURIOrConstant>
<t:Constant Value="MyExtendedPropertyValue" />
</t:FieldURIOrConstant>
</t:IsEqualTo>
</m:Restriction>
<m:ParentFolderIds>
<t:DistinguishedFolderId Id="sentitems" />
</m:ParentFolderIds>
</m:FindItem>
Note the XML tag containing the unique identifier.
<t:ExtendedFieldURI PropertySetId="20b5c09f-7cad-44c6-bdbf-8fcbeea08544" PropertyName="MyExtendedPropertyName" PropertyType="String" />
Solution 2:[2]
I could be missing the point, but after the save you can get appointment.Id which I believe is the unique id for this appointment. Store it somewhere and then later you can access the appointment again for edit or delete with:
Appointment appointment = Appointment.Bind(service, new ItemID("saved id value"));
After that you can change the values with the same properties that you used to set them originally and then issue:
appointment.Update(ConflictResolutionMode.AlwaysOverwrite);
or to delete:
appointment.Delete(DeleteMode.HardDelete);
You don't have to access the XML at all.
(n.b. As far I can tell you can't update or delete appointments from Public Folder calendars, although you can create them.)
Solution 3:[3]
Other way is to load the object after your action. But as it is said before, you can use the Appointment.Id.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | bitxwise |
| Solution 2 | Tony |
| Solution 3 | eL-Prova |
