GetAttachment Operation
TOC
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

GetAttachment Operation

Last modified: March 16, 2009

Applies to: Exchange Server 2007 | Exchange Server 2010

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

Description

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

Code

<?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>

Comments

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.

Note Note

The attachment identifier and change key have been shortened to preserve readability.

Request Elements

Description

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

Code

<?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>

Comments

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.

Successful Response Elements

Show:
© 2016 Microsoft