我一直在尝试弄清楚如何通过 C# 向多个收件人发送 Outlook 电子邮件。现在我可以在收件人之间进行循环,但是我的发件箱中将会有很多已发送的电子邮件。
Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
oMsg.HTMLBody ="test";
oMsg.Subject = "test" ;
Microsoft.Office.Interop.Outlook.Recipients oRecips = (Microsoft.Office.Interop.Outlook.Recipients)oMsg.Recipients;
Microsoft.Office.Interop.Outlook.Recipient oRecip = (Microsoft.Office.Interop.Outlook.Recipient)oRecips.Add("xxx@xxx.com");
oRecip.Resolve();
oMsg.Send();
oRecip = null;
oRecips = null;
oMsg = null;
oApp = null;
Run Code Online (Sandbox Code Playgroud)
如果我向其中添加多个地址,例如: (Microsoft.Office.Interop.Outlook.Recipient)oRecips.Add("xxx@xxx.com,yyy@yyy.com,zzz@zzz.com") 这将无法正常工作。谁可以帮我这个事?