SendItem 操作SendItem operation

SendItem 操作用于发送位于 Exchange 存储中的电子邮件。The SendItem operation is used to send e-mail messages that are located in the Exchange store.

SendItem (电子邮件)请求示例SendItem (E-mail Message) request example

DescriptionDescription

下面的示例演示如何发送电子邮件。The following example shows how to send an e-mail message.

代码Code

<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>
    <SendItem xmlns="https://schemas.microsoft.com/exchange/services/2006/messages" 
              SaveItemToFolder="true">
      <ItemIds>
        <t:ItemId Id="AAAtAEF=" ChangeKey="CQAAABY+T" />
      </ItemIds>
    </SendItem>
  </soap:Body>
</soap:Envelope>

备注Comments

项目标识符已缩短,以保持可读性。The item identifier has been shortened to preserve readability.

Request 元素Request elements

请求中使用以下元素:The following elements are used in the request:

成功的 SendItem (电子邮件)响应Successful SendItem (E-mail Message) Response

DescriptionDescription

下面的示例展示了一个成功的 SendItem 响应。The following example shows a successful SendItem response.

代码Code

<?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="602" MinorBuildNumber="0" 
                         xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" />
  </soap:Header>
  <soap:Body>
    <SendItemResponse 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:SendItemResponseMessage ResponseClass="Success">
          <m:ResponseCode>NoError</m:ResponseCode>
        </m:SendItemResponseMessage>
      </m:ResponseMessages>
    </SendItemResponse>
  </soap:Body>
</soap:Envelope>

成功的响应元素Successful response elements

响应中使用以下元素:The following elements are used in the response:

备注Comments

尝试发送位于主体的 "草稿" 文件夹中且设置为 "已发送邮件可分辨" 文件夹中的电子邮件的代理将以无提示方式将已发送项目的副本移动到 "已发送邮件" 可分辨文件夹中。A delegate who tries to send an e-mail message that is located in the principal's Drafts folder with the SendAndSaveCopy option set to save a copy in the Sent Items distinguished folder will silently fail to move a copy of the sent item to the Sent Items distinguished folder. 项目将保留在主体的 "草稿" 文件夹中。The item will remain in the principal's Drafts folder. 此问题的解决方法是在DistinguishedFolderId元素中指定主体的邮箱。The workaround for this issue is to specify the principal's mailbox in the DistinguishedFolderId element.

另一个需要考虑的方案是,当代理创建一封电子邮件并将其保存到代理邮箱的 "草稿" 文件夹中时。An additional scenario to consider is when a delegate creates an e-mail message and saves it to the Drafts folder of the delegate's mailbox. 如果代理尝试发送项目并将副本保存到主体的 "已发送邮件" 可分辨文件夹中,则邮件将被正确发送,草稿邮件仍保留在代理的 "草稿" 文件夹中,已发送的邮件不会显示在代理或主体的 "已发送邮件" 文件夹中,并且响应是成功的。If the delegate tries to send the item and save a copy to the principal's Sent Items distinguished folder, the message is sent correctly, the draft message remains in the delegate's Drafts folder, the sent message does not appear in either the delegate's or principal's Sent Items folder, and the response is a success.

无效的 SendItem (电子邮件)请求示例Invalid SendItem (E-mail Message) request example

DescriptionDescription

以下代码示例显示了带有无效标识符的请求示例。The following code sample shows an example of a request with an invalid identifier.

代码Code

<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>
    <SendItem xmlns="https://schemas.microsoft.com/exchange/services/2006/messages" 
              SaveItemToFolder="true">
      <ItemIds>
        <t:ItemId Id="%BadItemId%" ChangeKey="CQAAABYAAA" />
      </ItemIds>
    </SendItem>
  </soap:Body>
</soap:Envelope>

SendItem (电子邮件)错误响应SendItem (E-mail Message) error response

DescriptionDescription

下面的示例演示对包含无效标识符的 SendItem 请求的错误响应。The following example shows an error response to a SendItem request that contains an invalid identifier.

代码Code

<?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="602" MinorBuildNumber="0" 
                         xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" />
  </soap:Header>
  <soap:Body>
    <SendItemResponse 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:SendItemResponseMessage ResponseClass="Error">
          <m:MessageText>Id is malformed.</m:MessageText>
          <m:ResponseCode>ErrorInvalidIdMalformed</m:ResponseCode>
          <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
        </m:SendItemResponseMessage>
      </m:ResponseMessages>
    </SendItemResponse>
  </soap:Body>
</soap:Envelope>

错误响应元素Error response elements

错误响应中使用以下元素:The following elements are used in the error response:

另请参阅See also

SendItem 操作SendItem operation

SendItemTypeSendItemType