Microsoft Outlook 添加超链接到电子邮件 C#
使用 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");
}
When sending an e-mail using Microsoft Outlook I want to be able to send a hyperlink of file locations and websites in the body of the e-mail the body in my code is oMsg.Body. Any help would be greatly appreciated.
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");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从 MSDN 看来,您可以将
BodyFormat
设置为olFormatHTML
并使用HTMLBody
属性:从
HTMLBody
页面,看起来像这样如果您使用HTMLBody
属性,则会为您设置BodyFormat
,因此您应该能够跳过设置它。From MSDN, looks like you can set the
BodyFormat
toolFormatHTML
and use theHTMLBody
property:From the
HTMLBody
page, it looks like it sets theBodyFormat
for you if you use theHTMLBody
property, so you should be able to skip setting it.使用 HTML 作为正文而不是纯文本将允许您包含超链接的标记:
编辑:将
Body
属性更改为HTMLBody
属性。Using HTML for the Body instead of plain text will allow you to include markup for hyperlinks:
EDIT: Changed
Body
property toHTMLBody
property.