4.1 CreateAttachment Example

 The following is an example of a CreateAttachment operation, which creates an attachment named Deleteme.txt on the specified message. The item that it is attached to, which is represented by the ParentItemId element, is created separately. The Id attribute of the ParentItemId element has been shortened to preserve readability.

The client constructs the request XML and sends it to the server.

 <?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" />
   </soap:Header>
   <soap:Body>
     <m:CreateAttachment>
       <m:ParentItemId Id="AAMkAGIwODEy" />
       <m:Attachments>
         <t:FileAttachment>
           <t:Name>Deleteme.txt</t:Name>
           <t:IsInline>false</t:IsInline>
           <t:IsContactPhoto>false</t:IsContactPhoto>
           <t:Content>UGxlYXNlIGRlbGV0ZSB0aGlzIGZpbGUu</t:Content>
         </t:FileAttachment>
       </m:Attachments>
     </m:CreateAttachment>
   </soap:Body>
 </soap:Envelope>

The server constructs the response XML and sends it to the client. The Id, RootItemId, and RootItemChangeKey attributes of the AttachmentId element have been shortened to preserve readability.

 <?xml version="1.0" encoding="utf-8" ?>
 <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Header>
     <h:ServerVersionInfo MajorVersion="14" 
         MinorVersion="1" MajorBuildNumber="63" 
         MinorBuildNumber="0" 
         Version="Exchange2010" 
         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:CreateAttachmentResponse 
         xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" 
         xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
       <m:ResponseMessages>
         <m:CreateAttachmentResponseMessage ResponseClass="Success">
           <m:ResponseCode>NoError</m:ResponseCode>
           <m:Attachments>
             <t:FileAttachment>
               <t:AttachmentId Id="AAMkAGIwODEyY" RootItemId="AAMkAGIwODEyY" RootItemChangeKey="CQAAABYAAADL " />
             </t:FileAttachment>
           </m:Attachments>
         </m:CreateAttachmentResponseMessage>
       </m:ResponseMessages>
     </m:CreateAttachmentResponse>
   </s:Body>
 </s:Envelope>
Show: