2011-09-09 18 views
5

Al enviar un correo electrónico utilizando Microsoft Outlook, deseo poder enviar un hipervínculo de ubicaciones de archivos y sitios web en el cuerpo del correo electrónico, el cuerpo en mi código es oMsg.Body . Cualquier ayuda sería muy apreciada.Microsoft Outlook agregar hipervínculo al correo electrónico C#

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

Respuesta

5

El uso de HTML para el cuerpo en vez de texto plano se permitirá incluir marcado por los links:

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: Se cambió Body propiedad a HTMLBody propiedad.

+0

""; "

Web Site

"; aparece en el correo electrónico –

+0

trabajado perfecto Gracias –

7

De MSDN, parece que se puede establecer el BodyFormat a olFormatHTML y utilizar el HTMLBody propiedad:

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

Desde la página HTMLBody, parece que se establece el BodyFormat para usted si se utiliza la propiedad HTMLBody, por lo que debería poder omitir su configuración.

+2

+1 para señalar la propiedad HTMLBody. – RoccoC5

Cuestiones relacionadas