Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
DeleteAttachmentType Class
Collapse the table of content
Expand the table of content

DeleteAttachmentType Class

The DeleteAttachmentType class represents a request to delete an attachment on an item in the Exchange database.

System.Object
  ExchangeWebServices.BaseRequestType
    ExchangeWebServices.DeleteAttachmentType

Namespace:  ExchangeWebServices
Assembly:  EWS (in EWS.dll)

[SerializableAttribute]
public class DeleteAttachmentType : BaseRequestType

The DeleteAttachment operation returns the identifier and new change key of the item that held the attachment before it was deleted.

The following code example shows a DeleteItem request that deletes two attachments.

static void DeleteAttachment(ExchangeServiceBinding esb)
{
    // Create the request.
    DeleteAttachmentTyperequest = new DeleteAttachmentType();
    
    // Identify the attachments to delete.
    RequestAttachmentIdType[] attachments = new RequestAttachmentIdType[2];
    attachments[0] = new RequestAttachmentIdType();
    attachments[1] = new RequestAttachmentIdType();
    attachments[0].Id = "AAAlAE1B";
    attachments[1].Id = "AAAlAE1B";

    request.AttachmentIds = attachments;

    try
    {
        DeleteAttachmentResponseType response = esb.DeleteAttachment(request);
        ArrayOfResponseMessagesType aormt = response.ResponseMessages;
        ResponseMessageType[] rmta = aormt.Items;

        foreach (ResponseMessageType rmt in rmta)
        {
            DeleteAttachmentResponseMessageType darmt = (rmt as DeleteAttachmentResponseMessageType);

            if (darmt.ResponseClass == ResponseClassType.Success)
            {
                Console.WriteLine("Attachment deleted from ItemId: " + darmt.RootItemId.RootItemId);    
            }
        }
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
    }
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2015 Microsoft