MailItem-如何设置发件人

时间:2018-07-18 15:58:20

标签: c# outlook interop sender mailitem

我正在处理该项目,我需要使用STMP设置发送电子邮件。

我有以下代码:

SmtpClient client = new SmtpClient();

client.Host = Server;
client.UseDefaultCredentials = false;

string From = "lucashoberty@XXXXXX.com";

Microsoft.Office.Interop.Outlook.Application outlookApplication = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem email = (Microsoft.Office.Interop.Outlook.MailItem)outlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
email.VotingOptions = "Yes; No";
email.Subject = Subject;
email.Sender = From;
email.To = To;
email.HTMLBody = Body;
email.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceLow;
email.Display(false);
((Microsoft.Office.Interop.Outlook.MailItem)email).Send();

但是我无法设置发件人,因为我有一个字符串,并且variavel需要使用帐户进行设置。

我该怎么做?

0 个答案:

没有答案