GetAttachment 操作

GetAttachment 操作用于检索 Exchange 存储中项目的现有附件。

GetAttachment 请求示例

说明

以下示例的 GetAttachment 请求演示如何获取附件。

代码

<?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="https://schemas.microsoft.com/exchange/services/2006/types">
  <soap:Body>
    <GetAttachment xmlns="https://schemas.microsoft.com/exchange/services/2006/messages"
    xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">
      <AttachmentShape/>
      <AttachmentIds>
        <t:AttachmentId Id="AAAtAEFkbWluaX..."/>
      </AttachmentIds>
    </GetAttachment>
  </soap:Body>
</soap:Envelope>

Comments

AttachmentShape 元素允许指定应返回的附件信息。 空 AttachmentShape 元素有效,并且将呈现附件时不包含项目附件的 MIME 内容、文本正文类型,且不包含任何其他属性。

AttachmentIds 集合允许指定要返回的一个或多个附件标识符。 请注意,这些属性的类型为 RequestAttachmentIdType,因此从 CreateAttachment 接收的任何 AttachmentId 都必须删除 RootItemIdRootItemChangeKey 属性,然后再将它们传递给 GetAttachment

注意

附件标识符和更改键已缩短,以保持可读性。

请求元素

请求中使用以下元素:

GetAttachment 响应示例

说明

以下示例显示了对 GetAttachment 请求的成功响应。 此示例返回文件附件。

代码

<?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="https://schemas.microsoft.com/exchange/services/2006/types"/>
  </soap:Header>
  <soap:Body>
    <GetAttachmentResponse xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages" 
                           xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" 
                           xmlns="https://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

GetAttachment 的响应消息将始终包含完整的附件;也就是说,将始终包含所有属性。 对于文件附件,这些属性为 Name (AttachmentType) ContentTypeContentIdContentLocationContent。 对于项目附件,这些属性是 Name (AttachmentType) ContentTypeContentIdContentLocation 和项目的所有属性,就像在 GetItem 调用中使用 AllProperties 形状一样。 AttachmentShape 元素(如果存在)将允许使用者应用程序请求项目附件的其他扩展属性。

成功的响应元素

响应中使用以下元素:

另请参阅

CreateAttachment 操作

DeleteAttachment 操作