exchange-server - 使用保留 header 的 EWS 托管 API 转发电子邮件

标签 exchange-server ews-managed-api

我正在寻找有关如何使用托管 API 转发现有电子邮件(我的收件箱中已有)的示例代码。

转发时有没有办法在转发时保留邮件的原始 header ? 例如,有人向我发送了一封电子邮件 - 我希望 ews 将它转发给另一个收件人而不更改标题(原始接收时间,密件抄送等...)。

最佳答案

给定一个 EmailMessage 对象,您可以调用 CreateForwareMessage() 方法:

var forwareMessage = item.CreateForward();

关于另一个问题:获取邮件的MIME内容并附加到新邮件中:

item.Load(new PropertySet(BasePropertySet.IdOnly, ItemSchema.MimeContent));
var mail = new EmailMessage(service);
var attachment = mail.Attachments.AddFileAttachment("Original message.eml", item.MimeContent.Content);
attachment.ContentType = string.Format("message/rfc822; charset={0}", item.MimeContent.CharacterSet);
mail.ToRecipients.Add("hkrause@infinitec.de");
mail.Subject = "testmail";
mail.SendAndSaveCopy();

编辑:

创建转发消息并将回复设置为标题:

var fw = item.CreateForward();
var fwMsg = fw.Save(WellKnownFolderName.Drafts);
fwMsg.ReplyTo.Add("personA@company.com");
fwMsg.SendAndSaveCopy();

关于exchange-server - 使用保留 header 的 EWS 托管 API 转发电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7732911/

相关文章:

exchangewebservices - 使用 EWS 一次从 Exchange 2010 服务器获取所有通知

linux - 想要在 Perl-Linux 中获取 MS Exchange 属性

安卓服务连接

c# - EWS 托管 API - 使用 POP3/IMAP 的电子邮件客户端不显示自定义 header

active-directory - "Exchange Legacy Distinguished Name"和 "Active Directory Distingushed Name"有什么区别?

loops - 使用输入变量的PowerShell循环

c# - Exchange Web 服务托管 API : Accessing other users items

c# - 如何获得任务优先级

c# - 如何从 Exchange Server 2007 SP1 获取最新的 SyncState

.net - EWS 将 SendItem 报告为成功,但消息仍在草稿文件夹中