【问题标题】:How to get the ItemId of save-to-sent copy when sending mail via EWS通过 EWS 发送邮件时如何获取保存发送副本的 ItemId
【发布时间】:2015-12-09 05:49:57
【问题描述】:

EWS 文档说要发送消息并将副本保存到“已发送邮件”文件夹,您应该use the CreateItem operation with a MessageDisposition value of SendAndSaveCopy

   <m:CreateItem MessageDisposition="SendAndSaveCopy">
     <m:SavedItemFolderId>
       <t:DistinguishedFolderId Id="sentitems" />
     </m:SavedItemFolderId>
     <m:Items>
       <t:Message>
         <t:Subject>Company Soccer Team</t:Subject>
         <t:Body BodyType="HTML">Are you interested in joining?</t:Body>
         <t:ToRecipients>
           <t:Mailbox>
             <t:EmailAddress>sadie@contoso.com </t:EmailAddress>
           </t:Mailbox>
         </t:ToRecipients>
       </t:Message>
     </m:Items>
   </m:CreateItem>

成功时,“服务器使用 CreateItemResponse 消息响应 CreateItem 请求,该消息包含 NoError 的 ResponseCode 值,表示电子邮件已成功创建,以及新创建的消息的 ItemId。”

针对 Office 365 使用 EWS,这几乎成功。消息已发送,副本已保存到已发送项目...但已保存副本的 ItemId 在响应中返回:

   <m:CreateItemResponse>
     <m:ResponseMessages>
       <m:CreateItemResponseMessage ResponseClass="Success">
         <m:ResponseCode>NoError</m:ResponseCode>
         <m:Items />
       </m:CreateItemResponseMessage>
     </m:ResponseMessages>
   </m:CreateItemResponse>

有没有办法指示 EWS 服务器实际返回已保存副本的 ItemId?或者,发送完成后定位保存副本的首选机制是什么?

【问题讨论】:

  • 我应该注意我通过&lt;t:MimeContent CharacterSet="utf-8"&gt;...&lt;/t:MimeContent&gt; 指定出站消息。我不认为这应该有什么不同。
  • 在 SOAP 标头中指定 &lt;t:RequestServerVersion Version="Exchange2013" /&gt; 可能会导致 EWS 服务返回 ItemId。不幸的是,我的 EWS 客户端库不支持这个 RequestServerVersion 值,所以测试这个假设可能必须留给下一个人来解决这个问题......
  • 据我所知,设置 RequestServerVersion 不会改变响应。

标签: email office365 exchangewebservices


【解决方案1】:

显然,文档要么错误,要么不适用。 This MSDN blog post 符合我的经验:SendAndSaveCopy CreateItem 请求没有返回 ItemId。它提出以下建议:

Simply stamp your e-mail message with a custom extended property when you create the message, and then use that extended property to find the message in the Sent Items folder after it has been sent.

一位评论者建议,与其使用昂贵的 FindItems-with-SearchFilter 调用来定位带有自定义属性标记的已保存副本,不如执行以下操作:

1. Set your extended prop.

2. Do a FindItem with NO restriction against the sent items folder, SORTED by creation date descending with a indexed page view of about 5. Include your extended prop in the PropertySet.

3. Iterate across the results looking for your extended prop.

【讨论】:

    猜你喜欢
    • 2014-11-05
    • 1970-01-01
    • 2011-09-19
    • 1970-01-01
    • 1970-01-01
    • 2019-02-14
    • 2015-04-25
    • 2012-02-05
    • 2014-10-20
    相关资源
    最近更新 更多