![](/img/trans.png)
[英]How to remove "on behalf of " while sending mail from C# using Microsoft.Office.Interop.Outlook
[英]How to Choose from Multiple Profiles in Outlook while sending Email from C# using Interop
我在“ http://www.codeproject.com/Tips/165548/C-Code-snippet-to-send-an-Email-with-attachment-fr ”中找到了这段代码片段
// Create the Outlook application.
Outlook.Application oApp = new Outlook.Application();
// Create a new mail item.
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
// Set HTMLBody.
oMsg.HTMLBody = "Test"
//Subject line
oMsg.Subject = "Test Sub";
// Add a recipient.
Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
// Change the recipient in the next line if necessary.
Outlook.Recipient oRecip;
oRecip = (Outlook.Recipient)oRecips.Add(UserID);
oRecip.Resolve();
oRecip = (Outlook.Recipient)oRecips.Add(Recipients[i]);
oRecip.Resolve();
// Send.
oMsg.Send();
}
如果我在Outlook中配置了几个配置文件,我需要知道如何从特定的Outlook配置文件发送邮件。
先谢谢,Avirup。
我实际上从另一篇文章中找到了答案。 我们需要为不同的帐户设置一个配置文件名称,以下代码将执行以下操作:
Outlook.Account account = Application.Session.Accounts["MyOtherAccount"];
我试了一会儿这个问题,最后我只是使用电子邮件地址从Template .msg文件中发送。 显然,使用的模板可以是动态的(对我们来说,基于语言) -
Outlook.MailItem oMsg = (Outlook.MailItem)outlookApp.CreateItemFromTemplate("C:\\mail_templates\\template_"+lang+".msg");
我意识到这并没有回答问题,但这是我们解决的问题 - 它可能适用于您的情况,也可能不适合,但我希望它有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.