Compartir a través de


GetAttachmentType Clase

Definición

La GetAttachmentType clase representa una solicitud para obtener los elementos y archivos adjuntos en un elemento de una base de datos de Exchange.

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

Ejemplos

En el ejemplo de código siguiente se muestra una solicitud de obtención de datos adjuntos para dos datos adjuntos.

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);
    }
}

Comentarios

Use la llamada a GetItem para obtener los identificadores de datos adjuntos que se usarán en la operación GetAttachment.

Constructores

GetAttachmentType()

El GetAttachmentType constructor inicializa una nueva instancia de la GetAttachmentType clase .

Propiedades

AttachmentIds

La AttachmentIds propiedad obtiene o establece los identificadores de los datos adjuntos que se devolverán en la respuesta.

AttachmentShape

La AttachmentShape propiedad obtiene o establece las propiedades adicionales que se devolverán para los datos adjuntos.

Se aplica a