Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Outlook adding Hyperlink to Email C#

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");
    }
like image 714
Russell Saari Avatar asked Sep 09 '11 20:09

Russell Saari


1 Answers

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.

like image 162
SwDevMan81 Avatar answered Sep 28 '22 04:09

SwDevMan81