我有以下代码
public void SendMail2(string subject, string body, string emailAddress)
{
Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem mailItem = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
mailItem.Subject = subject;
mailItem.To = emailAddress;
mailItem.Body = body;
mailItem.SentOnBehalfOfName = "Some Name Already Setup";
mailItem.Display(false);
}
但是,当我调用程序中的方法时,我自己而不是预期收件人收到了电子邮件。有什么想法吗?
SentOnBehalfOfName
仅在通过Exchange发送时工作。它应该包含当前用户可以代表其发送的另一个Exchange用户的名称。
通过SMTP发送时,请改为设置MailItem.SendUsingAccount
属性。