Search code examples
c#exchange-serverexchangewebservicesews-managed-api

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

  • 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" />