Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将多个收件人添加到通过Microsoft.Office.Interop.Outlook.Application发送的电子邮件中?_C#_Email_Outlook_Outlook 2013 - Fatal编程技术网

C# 如何将多个收件人添加到通过Microsoft.Office.Interop.Outlook.Application发送的电子邮件中?

C# 如何将多个收件人添加到通过Microsoft.Office.Interop.Outlook.Application发送的电子邮件中?,c#,email,outlook,outlook-2013,C#,Email,Outlook,Outlook 2013,我每天上传一个数据库。无论何时上传完成,程序都会自动向某些收件人发送电子邮件。 我的前景是2013年专业版 using Microsoft.Office.Interop.Outlook; using OutlookApp = Microsoft.Office.Interop.Outlook.Application; OutlookApp outlookApp = new OutlookApp(); // Create a new mail item.

我每天上传一个数据库。无论何时上传完成,程序都会自动向某些收件人发送电子邮件。 我的前景是2013年专业版

using Microsoft.Office.Interop.Outlook;
using OutlookApp = Microsoft.Office.Interop.Outlook.Application;


 OutlookApp outlookApp = new OutlookApp();

                // Create a new mail item.
                //Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
                MailItem mailItem = outlookApp.CreateItem(OlItemType.olMailItem);

                // Set HTMLBody. 
                //add the body of the email

                mailItem.HTMLBody = "Prezados, a base " + Produto + " foi atualizada.<br>"
                    + "Data e hora local do upload: " + localDate.ToString("en-GB") +" " + localDate.Kind + "<br>"
                    + "Email gerado automaticamente."
                    ;
                //Subject line
                //oMsg.Subject =
                mailItem.Subject = "Atualização diária da base " + Produto
                // Add a recipient.
                Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;



                Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add("email_template@x.com");
                Outlook.Recipient oRecip1 = (Outlook.Recipient)oRecips.Add("email_template@x.com");
                Outlook.Recipient oRecip2 = (Outlook.Recipient)oRecips.Add("email_template@x.com");
                Outlook.Recipient oRecip3 = (Outlook.Recipient)oRecips.Add("email_template@x.com");

                oRecip.Resolve();
                oRecip1.Resolve();
                oRecip2.Resolve();
                oRecip3.Resolve();

                // Send.
                oMsg.Send();
                // Clean up.
                oRecip = null;
                oRecip1 = null;
                oRecip2 = null;
                oRecip3 = null;

                oRecips = null;
                oMsg = null;
                oApp = null;