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请求,该消息包含ResponseError的NoError,表示电子邮件已成功创建,以及新创建的消息的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?或者,一旦发送完成,找到保存的副本的首选机制是什么?
答案 0 :(得分:4)
显然,文档错误或不适用。 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.