GetAttachment Operation
The document is archived and information here might be outdated

GetAttachment Operation

Topic Last Modified: 2008-09-05

The GetAttachment operation is used to retrieve existing attachments on items in the Exchange store.

The following example of GetAttachment request shows how to get an attachment.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
  <soap:Body>
    <GetAttachment xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <AttachmentShape/>
      <AttachmentIds>
        <t:AttachmentId Id="AAAtAEFkbWluaX..."/>
      </AttachmentIds>
    </GetAttachment>
  </soap:Body>
</soap:Envelope>

The AttachmentShape element allows you to specify which attachment information should be returned. An empty AttachmentShape element is valid and will render your attachments without MIME content for item attachments, with a text body type, and without any additional properties.

The AttachmentIds collection allows you to specify one or more attachment identifiers to return. Note that these are of type RequestAttachmentIdType, so any AttachmentIds that you receive from CreateAttachment must have the RootItemId and RootItemChangeKey attributes removed before passing them to GetAttachment.

Aa494316.note(en-us,EXCHG.80).gifNote:
The attachment identifier and change key have been shortened to preserve readability.

The following example shows a successful response to a GetAttachment request. This example returns a file attachment.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <t:ServerVersionInfo MajorVersion="8" MinorVersion="0" MajorBuildNumber="662" MinorBuildNumber="0" 
                         xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"/>
  </soap:Header>
  <soap:Body>
    <GetAttachmentResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" 
                           xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" 
                           xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
      <m:ResponseMessages>
        <m:GetAttachmentResponseMessage ResponseClass="Success">
          <m:ResponseCode>NoError</m:ResponseCode>
          <m:Attachments>
            <t:FileAttachment>
              <t:AttachmentId Id="AAAtAEFkbWluaX..."/>
              <t:Name>SomeFile</t:Name>
              <t:Content>AQIDBAU=</t:Content>
            </t:FileAttachment>
          </m:Attachments>
        </m:GetAttachmentResponseMessage>
      </m:ResponseMessages>
    </GetAttachmentResponse>
  </soap:Body>
</soap:Envelope>

The response messages for GetAttachment will always contain the full attachment; that is, all properties will always be included. For file attachments, those properties are Name (AttachmentType), ContentType, ContentId, ContentLocation, and Content. For item attachments, those properties are Name (AttachmentType), ContentType, ContentId, ContentLocation and all of the item’s properties, as if the AllProperties shape had been used in a GetItem call. The AttachmentShape element, if present, will allow a consumer application to request additional extended properties for item attachments.

Show:
© 2016 Microsoft