4.3 GetAttachment Example

 The following is an example of a GetAttachment operation. This example gets an attachment from the server store.

The client constructs the request XML and sends it to the server. The Id attribute of the AttachmentId element has been shortened to preserve readability.

 <?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:GetAttachment>
       <m:AttachmentIds>
         <t:AttachmentId Id="AAMkAGY4YzQw" />
       </m:AttachmentIds>
     </m:GetAttachment>
   </soap:Body>
 </soap:Envelope>

The server constructs the response XML and sends it to the client. In this example, there is one attachment in the attachments collection. The Id attribute of the AttachmentId element has been shortened to preserve readability. Note that the content is base64.

 <?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:GetAttachmentResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" 
         xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
       <m:ResponseMessages>
         <m:GetAttachmentResponseMessage ResponseClass="Success">
           <m:ResponseCode>NoError</m:ResponseCode>
           <m:Attachments>
             <t:FileAttachment>
               <t:AttachmentId Id="AAMkAGY4YzQw" />
               <t:Name>Deleteme.txt</t:Name>
               <t:Content>UGxlYXNlIGRlbGV0ZSB0aGlzIHRleHQu</t:Content>
             </t:FileAttachment>
           </m:Attachments>
         </m:GetAttachmentResponseMessage>
       </m:ResponseMessages>
     </m:GetAttachmentResponse>
   </s:Body>
 </s:Envelope>