Compartir a través de


DeleteAttachment Operation

Last modified: March 16, 2009

Applies to: Exchange Server 2007 | Exchange Server 2010

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="https://schemas.xmlsoap.org/soap/envelope/"
               xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">
  <soap:Body>
    <DeleteAttachment xmlns="https://schemas.microsoft.com/exchange/services/2006/messages"
                      xmlns:t="https://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="https://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>
    <DeleteAttachmentResponse 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: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