如何将通过 EWS 创建的所有电子邮件标记为收入邮件而不是草稿?

How can I mark all created emails through EWS as income mails and not drafts?

只是想问一下我在使用 EWS 和创建邮件时遇到的这个问题。

我正在创建电子邮件并将其保存到我的收件箱。

            EmailMessage message = new EmailMessage(_exchangeService);
            message.From = emailObject.SenderAddress;
            message.Subject = emailObject.Subject;
            message.Body = emailObject.Body
            message.ToRecipients.Add(email);
            message.CcRecipients.Add(emailObject.CC);
            message.IsRead = false;
            message.Save(WellKnownFolderName.Inbox);

现在的问题是,EWS 正在将电子邮件创建为草稿。

是否可以将邮件标记为收入邮件?

谢谢!

如果我猜对了,你想把它发给自己吗?

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("recipient@bar.com");
message.Subject = "Important";
message.From = new System.Net.Mail.MailAddress("sender@bar.com");
message.Body = "Message";

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("your.exchange.instance.url");
try
{
    smtp.Send(message);
}
catch (SmtpFailedRecipientException ex)
{
    throw ex;
}

您需要使用扩展 属性 在消息上设置 PR_Message_Flags https://msdn.microsoft.com/en-us/library/ee160304(v=exchg.80).aspx 属性,这将使消息显示为已发送

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