AttachmentType Classe

Definição

O AttachmentType classe representa um anexo.

public ref class AttachmentType
public class AttachmentType
Public Class AttachmentType
Herança
AttachmentType
Derivado

Exemplos

O exemplo a seguir mostra o uso do FileAttachmentType e o ItemAttachmentType. Esses dois tipos de são derivados do AttachmentType classe. Esses dois tipos são adicionados ao Attachments propriedade do CreateAttachmentType classe. Este exemplo também mostra o uso do AttachmentType no AttachmentInfoResponseMessageType objeto.

static void CreateAttachment(ExchangeServiceBinding esb)
{
    // Create item attachment.
    MessageType message = new MessageType();
    message.Subject = "Example subject";
    message.Importance = ImportanceChoicesType.Low;
    message.ImportanceSpecified = true;

    ItemAttachmentType itemAttach = new ItemAttachmentType();
    itemAttach.Name = "Message Attachment Example";
    itemAttach.Item = message;

    // Create file attachment.
    FileAttachmentType fileAttach = new FileAttachmentType();
    fileAttach.Name = "filename.txt";
    fileAttach.ContentType = "text/plain";

    byte[] content;
    using (FileStream fileStream = new FileStream("C:\\cas.txt",
        FileMode.Open, FileAccess.Read))
    {
        content = new byte[fileStream.Length];
        fileStream.Read(content, 0, content.Length);
    }

    fileAttach.Content = content;

    // Create the CreateAttachment request.
    CreateAttachmentTypereqCreateAttach = new CreateAttachmentType();

    // Identify the item that will have the attachments.
    ItemIdType item = new ItemIdType();
    item.Id = "AAAlAE1BQG1h";
    item.ChangeKey = "DwAAABYAAA"; 

    // Add the parent item to the request.
    reqCreateAttach.ParentItemId = item;

    // Add attachments to the request.
    reqCreateAttach.Attachments = new AttachmentType[2];
    reqCreateAttach.Attachments[0] = itemAttach;
    reqCreateAttach.Attachments[1] = fileAttach;

    try
    {
        CreateAttachmentResponseType resp = esb.CreateAttachment(reqCreateAttach);
        ArrayOfResponseMessagesType aorit = resp.ResponseMessages;
        ResponseMessageType[] rmta = aorit.Items;

        foreach (ResponseMessageType rmt in rmta)
        {
            if (rmt.ResponseClass == ResponseClassType.Success)
            {
                AttachmentInfoResponseMessageType airmt = rmt as AttachmentInfoResponseMessageType;
                foreach (AttachmentType atch in airmt.Attachments)
                {
                    if (atch is ItemAttachmentType)
                    {
                        Console.WriteLine("Created item attachment");
                    }
                    else if (atch is FileAttachmentType)
                    {
                        Console.WriteLine("Created file attachment");
                    }
                    else
                    {
                        throw new Exception("Unknown attachment");
                    }
                }
            }
        }
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
    }
}

Comentários

O AttachmentType classe pode representar um arquivo ou um anexo do item. O AttachmentType classe é o tipo de base para o FileAttachmentType e o ItemAttachmentType classes.

Construtores

AttachmentType()

O AttachmentType construtor inicializa uma nova instância do AttachmentType classe.

Propriedades

AttachmentId

O AttachmentId propriedade obtém ou define o identificador do anexo. Essa propriedade é leitura/gravação.

ContentId

O ContentId propriedade obtém ou define o identificador de conteúdo de anexo. Essa propriedade é leitura/gravação.

ContentLocation

O ContentLocation propriedade obtém ou define o identificador URI (Uniform Resource) que corresponde a até o local do conteúdo do anexo. Esta propriedade é somente leitura.

ContentType

O ContentType propriedade obtém ou define um valor que descreve o tipo de email extensões MIME (Multipurpose Internet) do conteúdo do anexo.

IsInline

O IsInline propriedade obtém ou define um valor Boolean que especifica se o anexo é exibido embutida dentro de um item.

IsInlineSpecified

O IsInlineSpecified propriedade obtém um valor Boolean que especifica se o IsInline propriedade é serializada na solicitação SOAP. Esta propriedade é somente leitura.

LastModifiedTime

O LastModifiedTime propriedade obtém um valor de data/hora que especifica a última modificação do anexo.

LastModifiedTimeSpecified

O LastModifiedTimeSpecified propriedade obtém um valor Boolean que especifica se o LastModifiedTime propriedade é serializada na solicitação SOAP. Esta propriedade é somente leitura.

Name

O Name propriedade obtém ou define o nome do anexo.

Size

O Size propriedade obtém ou define um valor integer que representa o tamanho em bytes de um anexo.

SizeSpecified

O SizeSpecified propriedade obtém um valor Boolean que especifica se o SizeSpecified propriedade é serializada na solicitação SOAP. Esta propriedade é somente leitura.

Aplica-se a