C#和EWS如何将消息另存为电子邮件而不是草稿

问题描述 投票:1回答:1

到目前为止,我要做的是连接到EWS,访问我的收件箱,创建一个项目(电子邮件),并在正文,主题,发件人和收件人中添加一些信息,将其保存到草稿文件夹,最后将其移动到我的收件箱。它有效,但是,我在收件箱中收到草稿,而不是电子邮件。

在上述情况下是否可以通过电子邮件获得消息,我该如何实现?

下面是我的代码。任何输入将不胜感激。

try {
    message.Save();
}
catch(Exception e21) {;
}

message.Load(PS);

message.From = new EmailAddress("[email protected]");
message.ToRecipients.Add("[email protected]");
message.Body = "This is A test take 1";
message.Subject = "Testing to send as someone else...";
// add in the attachments......
message.Update(ConflictResolutionMode.AlwaysOverwrite); // require this here  why????
message.Copy(theTempFolder.Id); // get the item as a draft in my mailbox instead of an email 
}
catch(Exception e99) {
    Console.WriteLine("Exception fail to connect to office 365 on the cloud: " + e99.Message);
}
c# exchangewebservices
1个回答
0
投票

您需要将MessageFlags属性https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagmessageflags-canonical-property设置为1(在调用更新之前,例如,]

ExtendedPropertyDefinition PR_MESSAGE_FLAGS_msgflag_read = new ExtendedPropertyDefinition(3591, MapiPropertyType.Integer);
message.SetExtendedProperty(PR_MESSAGE_FLAGS_msgflag_read, 1);

然后,它将使该邮件看起来像已收到。另一种方法是只导入EML,例如https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-import-items-by-using-ews-in-exchange

© www.soinside.com 2019 - 2024. All rights reserved.