Microsoft Outlook 添加超链接到电子邮件 C#

发布于 2024-12-03 14:11:40 字数 1076 浏览 1 评论 0原文

使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深陷 2024-12-10 14:11:40

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,因此您应该能够跳过设置它。

From MSDN, looks like you can set the BodyFormat to olFormatHTML and use the HTMLBody property:

oMsg.BodyFormat = olFormatHTML; // <-- Probably dont need this
oMsg.HTMLBody = "<HTML><BODY>Enter the message text here.</BODY></HTML>";

From the HTMLBody page, it looks like it sets the BodyFormat for you if you use the HTMLBody property, so you should be able to skip setting it.

揽清风入怀 2024-12-10 14:11:40

使用 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 属性。

Using HTML for the Body instead of plain text will allow you to include markup for hyperlinks:

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>";

EDIT: Changed Body property to HTMLBody property.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文