DeleteAttachmentType Class

Definition

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

public ref class DeleteAttachmentType : ExchangeWebServices::BaseRequestType
public class DeleteAttachmentType : ExchangeWebServices.BaseRequestType
Public Class DeleteAttachmentType
Inherits BaseRequestType
Inheritance
DeleteAttachmentType

Examples

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

static void DeleteAttachment(ExchangeServiceBinding esb)
{
    // Create the request.
<span class="label">DeleteAttachmentType</span><span class="label">request</span> = 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";

<span class="label">request</span>.AttachmentIds = attachments;

    try
    {
        DeleteAttachmentResponseType response = esb.DeleteAttachment(<span class="label">request</span>);
        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);
    }
}

Remarks

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

Constructors

DeleteAttachmentType()

The DeleteAttachmentType constructor initializes a new instance of the DeleteAttachmentType class.

Properties

AttachmentIds

The AttachmentIds property gets or sets the set of attachment identifiers that are used to identify the attachments to delete.

Applies to