gpt4 book ai didi

c# - Microsoft Outlook 将抄送添加到电子邮件

转载 作者:行者123 更新时间:2023-11-30 21:12:36 24 4
gpt4 key购买 nike

我目前已有代码可以自动执行电子邮件和发送文件。我现在需要添加一个抄送。我已经四处寻找,但似乎无法用我现有的代码找出答案。任何帮助将不胜感激。谢谢。

         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@email.com");
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");
}

最佳答案

根据 MSDN,MailItem 类上有一个 CC 属性。

string CC { get; set; }

可用于设置抄送收件人的姓名。

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._mailitem.cc.aspx

要修改收件人,您可以将他们添加到收件人集合中:

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.recipients.aspx

你会这样使用:

oMsg.Recipients.Add("foo@bar.com");

关于c# - Microsoft Outlook 将抄送添加到电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7390341/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com