我正在处理该项目,我需要使用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需要使用帐户进行设置。
我该怎么做?