2
我目前有現有的代碼可以自動執行併發送電子郵件和發送文件。我現在需要添加一個cc。我已經看遍了所有,但似乎無法找到與我現有的代碼。任何幫助將不勝感激。謝謝。Microsoft Outlook將cc添加到電子郵件
private void button13_Click(object sender, EventArgs e)
{
//Send Routing and Drawing to Dan
// Create the Outlook application by using inline initialization.
Outlook.Application oApp = new Outlook.Application();
//Create the new message by using the simplest approach.
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
//Add a recipient
Outlook.Recipient oRecip = (Outlook.Recipient)oMsg.Recipients.Add("[email protected]");
oRecip.Resolve();
//Set the basic properties.
oMsg.Subject = "Job # " + textBox9.Text + " Release (" + textBox1.Text + ")";
oMsg.HTMLBody = "<html><body>";
oMsg.HTMLBody += "Job # " + textBox9.Text + " is ready for release attached is the Print and Routing (" + textBox1.Text + ")";
oMsg.HTMLBody += "<p><a href='C:\\Users\\RussellS\\Desktop\\Russell Eng Reference\\" + textBox1.Text + ".PDF'>" + textBox1.Text + " Drawing";
oMsg.HTMLBody += "<p><a href='C:\\Users\\RussellS\\Desktop\\" + textBox1.Text + ".PDF'>" + textBox1.Text + " Routing" + "</a></p></body></html>";
//Send the message
oMsg.Send();
//Explicitly release objects.
oRecip = null;
oMsg = null;
oApp = null;
MessageBox.Show(textBox1.Text + " Print and Routing Sent");
}
的實際工作,但它增加到的TO:在展望,而不是cc,所以我會以某種方式不得不在字符串中的CC字符串? –
據我所知,將CC收件人的名稱設置爲與收件人集合中的收件人匹配的東西就足夠了。 –
我知道這個答案被接受,我只是想補充一點,微軟建議你通過收件人收集來操作收件人。 To,CC和BCC屬性應僅用於讀取收件人。要設置CC收件人,您可以在Jamie上面添加新收件人的代碼之後立即將Type屬性設置爲olCC(或對於BCC收件人爲olBCC)。 – JimmyPena