Freigeben über


GetAttachmentType Klasse

Definition

Die GetAttachmentType -Klasse stellt eine Anforderung zum Abrufen angefügter Elemente und Dateien für ein Element in einer Exchange-Datenbank dar.

public ref class GetAttachmentType : ExchangeWebServices::BaseRequestType
public class GetAttachmentType : ExchangeWebServices.BaseRequestType
Public Class GetAttachmentType
Inherits BaseRequestType
Vererbung
GetAttachmentType

Beispiele

Das folgende Codebeispiel zeigt eine Anforderung zum Abrufen von Anlagen für zwei Anlagen.

static void GetAttachment(ExchangeServiceBinding esb)
{
    // Create the request.
<span class="label">GetAttachmentType</span><span class="label">request</span> = new GetAttachmentType();

    // Create the response shape.
    AttachmentResponseShapeType responseShape = new AttachmentResponseShapeType();
    responseShape.BodyType = BodyTypeResponseType.Text;
    responseShape.BodyTypeSpecified = true;

    // Add the response shape to the request.
<span class="label">request</span>.AttachmentShape = responseShape;

    // Identify the attachment IDs to get.
    RequestAttachmentIdType[] ids = new RequestAttachmentIdType[2];
    ids[0] = new RequestAttachmentIdType();
    ids[1] = new RequestAttachmentIdType();
    ids[0].Id = "AAAlAE1BQG1";
    ids[1].Id = "AAAlAE1Bas";

    // Add the attachment IDs to the request.
<span class="label">request</span>.AttachmentIds = ids;

    try
    {
        GetAttachmentResponseType response = esb.GetAttachment(<span class="label">request</span>);
        ResponseMessageType[] rmta = response.ResponseMessages.Items;

        foreach (ResponseMessageType responseMessage in rmta)
        { 
            AttachmentInfoResponseMessageType airmt = (responseMessage as AttachmentInfoResponseMessageType);
            AttachmentType[] attachments = airmt.Attachments;

            // Type check for item or file attachment.
            foreach (AttachmentType attachment in attachments)
            {
                if (attachment is FileAttachmentType)
                {
                    FileAttachmentType fat = (attachment as FileAttachmentType);

                    // Assumes ASCII encoding.
                    string myContent = ASCIIEncoding.ASCII.GetString(fat.Content);
                }

                // Attachment is item attachment.
                else
                {
                    ItemAttachmentType iat = (attachment as ItemAttachmentType);
                    // TODO: Handle the item attachment.
                }
            }
        }
    }
    catch (Exception x)
    {
        Console.WriteLine(x.Message);
    }
}

Hinweise

Verwenden Sie den GetItem-Aufruf, um die Anlagenbezeichner abzurufen, die im GetAttachment-Vorgang verwendet werden sollen.

Konstruktoren

GetAttachmentType()

Der GetAttachmentType Konstruktor initialisiert eine neue Instanz der GetAttachmentType -Klasse.

Eigenschaften

AttachmentIds

Die AttachmentIds -Eigenschaft ruft die Bezeichner der Anlagen ab, die in der Antwort zurückgegeben werden sollen, oder legt diese fest.

AttachmentShape

Die AttachmentShape -Eigenschaft ruft ab oder legt fest, welche zusätzlichen Eigenschaften für die Anlagen zurückgegeben werden sollen.

Gilt für: