Operação CreateAttachmentCreateAttachment operation

A operação CreateAttachment cria um item ou anexo de arquivo e anexa-o ao item especificado.The CreateAttachment operation creates either an item or file attachment and attaches it to the specified item.

Exemplo de solicitação de CreateAttachment de arquivoFile CreateAttachment request example

DescriçãoDescription

O exemplo a seguir de uma solicitação de CreateAttachment mostra como criar um anexo de arquivo.The following example of a CreateAttachment request shows how to create a file attachment.

CódigoCode

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">
<soap:Body>
  <CreateAttachment xmlns="https://schemas.microsoft.com/exchange/services/2006/messages"
                    xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">
    <ParentItemId Id="AAAtAE..." ChangeKey="CQAAABYA..."/>
    <Attachments>
      <t:FileAttachment>
        <t:Name>SomeFile</t:Name>
        <t:Content>AQIDBAU=</t:Content>
      </t:FileAttachment>
    </Attachments>
  </CreateAttachment>
</soap:Body>
</soap:Envelope>

ComentárioComment

Deve ser fornecido um nome para o anexo.A name for the attachment must be provided.

Observação

O identificador de item pai e a chave de alteração foram reduzidos para preservar a legibilidade.The parent item identifier and change key have been shortened to preserve readability.

Elementos RequestRequest elements

Os seguintes elementos são usados na solicitação:The following elements are used in the request:

Exemplo de resposta de CreateAttachment de arquivo bem-sucedidoSuccessful File CreateAttachment response example

DescriçãoDescription

O exemplo a seguir mostra uma resposta bem-sucedida à solicitação CreateAttachment.The following example shows a successful response to the CreateAttachment request.

CódigoCode

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <t:ServerVersionInfo MajorVersion="8" MinorVersion="0" MajorBuildNumber="653" MinorBuildNumber="0" 
                         xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types"/>
  </soap:Header>
  <soap:Body>
    <CreateAttachmentResponse xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages" 
                              xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" 
                              xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
      <m:ResponseMessages>
        <m:CreateAttachmentResponseMessage ResponseClass="Success">
          <m:ResponseCode>NoError</m:ResponseCode>
          <m:Attachments>
            <t:FileAttachment>
              <t:AttachmentId Id="AAAtAE=" RootItemId="AAAtAEFk=" RootItemChangeKey="CQAAAB"/>
            </t:FileAttachment>
          </m:Attachments>
        </m:CreateAttachmentResponseMessage>
      </m:ResponseMessages>
    </CreateAttachmentResponse>
  </soap:Body>
</soap:Envelope>

ComentárioComment

A resposta contém o identificador do arquivo anexado.The response contains the identifier of the attached file. Ele também contém o identificador e a chave de alteração do item raiz.It also contains the identifier and change key of the root item. Os identificadores de item e a chave de alteração foram reduzidos para preservar a legibilidade.The item identifiers and change key have been shortened to preserve readability.

Elementos de resposta bem-sucedidosSuccessful response elements

Os seguintes elementos são usados na resposta:The following elements are used in the response:

Exemplo de solicitação de CreateAttachment de itemItem CreateAttachment request example

DescriçãoDescription

O exemplo a seguir de uma solicitação de CreateAttachment mostra como criar um anexo de item.The following example of a CreateAttachment request shows how to create an item attachment.

CódigoCode

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">
  <soap:Body>
    <CreateAttachment xmlns="https://schemas.microsoft.com/exchange/services/2006/messages"
                      xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">
      <ParentItemId Id="AAAtAE=" ChangeKey="CQAAABYA"/>
      <Attachments>
        <t:ItemAttachment>
          <t:Name>An item attachment</t:Name>
          <t:Message>
            <t:Subject>A message to attach</t:Subject>
          </t:Message>
        </t:ItemAttachment>
      </Attachments>
    </CreateAttachment>
  </soap:Body>
</soap:Envelope>

ComentárioComment

Deve ser fornecido um nome para o anexo.A name for the attachment must be provided.

Observação O identificador de item pai e a chave de alteração foram reduzidos para preservar a legibilidade.Note The parent item identifier and change key have been shortened to preserve readability.

Elementos RequestRequest elements

Os seguintes elementos são usados na solicitação:The following elements are used in the request:

Exemplo de resposta de CreateAttachment de item bem-sucedidoSuccessful Item CreateAttachment response example

DescriçãoDescription

O exemplo a seguir mostra uma resposta bem-sucedida à solicitação CreateAttachment.The following example shows a successful response to the CreateAttachment request.

CódigoCode

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <t:ServerVersionInfo MajorVersion="8" MinorVersion="0" MajorBuildNumber="653" MinorBuildNumber="0" 
                         xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types"/>
  </soap:Header>
  <soap:Body>
    <CreateAttachmentResponse xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages" 
                              xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" 
                              xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
      <m:ResponseMessages>
        <m:CreateAttachmentResponseMessage ResponseClass="Success">
          <m:ResponseCode>NoError</m:ResponseCode>
          <m:Attachments>
            <t:ItemAttachment>
              <t:AttachmentId Id="AAAtAEFk=" RootItemId="AAAtAEFkb=" RootItemChangeKey="CQAAABYA"/>
            </t:ItemAttachment>
          </m:Attachments>
        </m:CreateAttachmentResponseMessage>
      </m:ResponseMessages>
    </CreateAttachmentResponse>
  </soap:Body>
</soap:Envelope>

ComentárioComment

A resposta contém o identificador do novo anexo.The response contains the identifier of the new attachment. Ele também contém o identificador e a chave de alteração do item raiz.It also contains the identifier and change key of the root item. O item raiz é o item que contém o anexo.The root item is the item that contains the attachment. Os identificadores de item e a chave de alteração foram reduzidos para preservar a legibilidade.The item identifiers and change key have been shortened to preserve readability.

Elementos de resposta bem-sucedidosSuccessful response elements

Os seguintes elementos são usados na resposta:The following elements are used in the response:

Exemplo de resposta de erro CreateAttachmentCreateAttachment Error response example

DescriçãoDescription

O exemplo a seguir mostra uma resposta de erro para a solicitação de CreateAttachment.The following example shows an error response to the CreateAttachment request. O erro se deve ao fato de que o nome do anexo não foi especificado.The error is due to the fact that the name of the attachment was not specified.

CódigoCode

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <t:ServerVersionInfo MajorVersion="8" MinorVersion="0" MajorBuildNumber="653" MinorBuildNumber="0" 
                         xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types"/>
  </soap:Header>
  <soap:Body>
    <CreateAttachmentResponse xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages" 
                              xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" 
                              xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
      <m:ResponseMessages>
        <m:CreateAttachmentResponseMessage ResponseClass="Error">
          <m:MessageText>Required property is missing.</m:MessageText>
          <m:ResponseCode>ErrorRequiredPropertyMissing</m:ResponseCode>
          <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
          <m:MessageXml>
            <t:ExceptionFieldURI FieldURI="attachment:Name"/>
          </m:MessageXml>
          <m:Attachments/>
        </m:CreateAttachmentResponseMessage>
      </m:ResponseMessages>
    </CreateAttachmentResponse>
  </soap:Body>
</soap:Envelope>

Elementos de resposta de erroError response elements

Os seguintes elementos são usados na resposta de erro:The following elements are used in the error response:

ComentáriosRemarks

Se vários anexos estiverem anexados a um item em uma única viagem de ida e volta, o RootItemChangeKey na última mensagem de resposta será aquele que representa a nova chave de alteração do item que tem os anexos.If multiple attachments are attached to an item in a single round trip, the RootItemChangeKey in the last response message is the one that represents the new change key of the item that has the attachments.

Confira tambémSee also

Operação DeleteAttachmentDeleteAttachment operation

Operação GetAttachmentGetAttachment operation