Microsoft Outlook为Email c#添加超链接
本文关键字:添加 超链接 Email Outlook Microsoft | 更新日期: 2023-09-27 18:08:02
当使用Microsoft Outlook发送电子邮件时,我希望能够在电子邮件的正文中发送文件位置和网站的超链接,我的代码正文是oMsg.Body。如有任何帮助,我将不胜感激。
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-address here");
oRecip.Resolve();
//Set the basic properties.
oMsg.Subject = textBox1.Text + " Job Release";
oMsg.Body = textBox1.Text + " is ready for release attached is the Print and Routing";
//Send the message. 6
oMsg.Send();
//Explicitly release objects.
oRecip = null;
oMsg = null;
oApp = null;
MessageBox.Show("Print and Routing Sent");
}
从MSDN中,看起来可以将BodyFormat
设置为olFormatHTML
并使用HTMLBody
属性:
oMsg.BodyFormat = olFormatHTML; // <-- Probably dont need this
oMsg.HTMLBody = "<HTML><BODY>Enter the message text here.</BODY></HTML>";
从HTMLBody
页来看,如果您使用HTMLBody
属性,它似乎为您设置了BodyFormat
,因此您应该能够跳过设置它。
使用HTML代替纯文本将允许你为超链接包含标记:
oMsg.HTMLBody = "<html><body>";
oMsg.HTMLBody += textBox1.Text + " is ready for release attached is the Print and Routing";
oMsg.HTMLBody += "<p><a href='http://website.com'>Web Site</a></p></body></html>";
编辑:更改Body
属性为HTMLBody
属性