編輯

共用方式為


DeleteAttachment operation

The DeleteAttachment operation is used to delete file and item attachments from an existing item in the Exchange store.

Remarks

This operation allows you to delete one or more attachments by ID.

DeleteAttachment request example

Description

The following example of a DeleteAttachment request shows how to delete an item 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>
    <DeleteAttachment xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
                      xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <AttachmentIds>
        <t:AttachmentId Id="AAAtAEFkbWluaX"/>
      </AttachmentIds>
    </DeleteAttachment>
  </soap:Body>
</soap:Envelope>

Comments

The attachment identifier has been shortened to preserve readability.

Request elements

The following elements are used in the request:

DeleteAttachment response example

Description

The following example shows a successful response to a DeleteAttachment request.

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>
    <DeleteAttachmentResponse 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:DeleteAttachmentResponseMessage xsi:type="m:DeleteAttachmentResponseMessageType" ResponseClass="Success">
          <m:ResponseCode>NoError</m:ResponseCode>
          <m:RootItemId RootItemId="AAAtAEFkbWluaXN..." RootItemChangeKey="CQAAABYAA..."/>
        </m:DeleteAttachmentResponseMessage>
      </m:ResponseMessages>
    </DeleteAttachmentResponse>
  </soap:Body>
</soap:Envelope>

Comments

The CreateAttachment operation returns an element of AttachmentIdType type that includes a RootItemId and RootItemChangeKey. These attributes are not permitted for identifiers within a DeleteAttachment request. DeleteAttachment uses elements of type RequestAttachmentIdType, which does not include these attributes.

The DeleteAttachment response includes the ID of the parent item. When attachments are removed from an item, the item's change key is modified. The new item change key can be obtained from the DeleteAttachment response.

Note

The RootItemId identifier and ChangeKey have been shortened to preserve readability.

Successful response elements

The following elements are used in the response:

See also