简体   繁体   English

使用EWS托管API更改回复时的发件人

[英]Change sender on reply using EWS Managed API

I'm currently trying to configure Mail2Bug to create Bugs in Azure DevOps when new emails arrive in a shared mailbox. 我当前正在尝试将Mail2Bug配置为在新电子邮件到达共享邮箱时在Azure DevOps中创建错误。 Everything was going well until the part where it needs to reply to the incoming message. 一切进展顺利,直到需要回复传入消息的部分为止。

The code which handles this function can be found in EWSIncomingMessage.cs : 处理此功能的代码可以在EWSIncomingMessage.cs中找到:

 public void Reply(string replyHtml, bool replyAll)
 {
     //_message is of type EmailMessage
     var reply = _message.CreateReply(replyAll);
     reply.BodyPrefix = new MessageBody(BodyType.HTML, replyHtml);
     reply.Send();
 }

Instead of replying using the shared mailbox's email, it uses the one from the authenticated user. 它不使用共享邮箱的电子邮件进行回复,而是使用经过身份验证的用户的电子邮件。 I'm assuming this has to do with how CreateReply populates the reply MailMessage in combination with EWS. 我假设这与CreateReply如何结合EWS填充回复MailMessage有关。

Are there any ways around this (possibly by creating a new MailMessage and simulate a reply)? 有没有解决的办法(可能是通过创建新的MailMessage并模拟回复)?

You could refer to the below code: 您可以参考以下代码:

var message = (EmailMessage) Item.Bind(service, new ItemId(uniqueId), PropertySet.FirstClassProperties);
var reply = message.CreateReply(false);
reply.BodyPrefix = "Response text goes here";
var replyMessage = reply.Save(WellKnownFolderName.Drafts);
replyMessage.Attachments.AddFileAttachment("d:\\inbox\\test.pdf");
replyMessage.Update(ConflictResolutionMode.AlwaysOverwrite);
replyMessage.SendAndSaveCopy();

For more information, please refer to these links: 有关更多信息,请参考以下链接:

Replying with attachments to an email message with EWS 使用EWS回复电子邮件的附件

How to reply to an email using the EWS Managed API? 如何使用EWS托管API回复电子邮件?

Respond to email messages by using EWS in Exchange 在Exchange中使用EWS响应电子邮件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM