2011-09-09 12 views
5

Quando si invia un messaggio di posta elettronica tramite Microsoft Outlook, desidero essere in grado di inviare un collegamento ipertestuale dei percorsi dei file e dei siti Web nel corpo dell'e-mail il corpo nel mio codice è oMsg.Body . Qualsiasi aiuto sarebbe molto apprezzato.Microsoft Outlook aggiungendo collegamento ipertestuale all'e-mail 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"); 
    } 

risposta

5

Utilizzando HTML per il corpo, invece di solo testo vi permetterà di includere markup per i collegamenti ipertestuali:

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: Cambiato Body proprietà HTMLBody proprietà.

+0

""; "

Web Site

"; visualizzato nell'e-mail –

+0

Perfetto perfetto Grazie –

7

Da MSDN, si presenta come è possibile impostare il BodyFormat per olFormatHTML e utilizzare la proprietà HTMLBody:

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

Dalla pagina HTMLBody, sembra che imposta il BodyFormat per voi, se si utilizza la proprietà HTMLBody, quindi dovresti essere in grado di saltare impostandolo.

+2

+1 per indicare la proprietà HTMLBody. – RoccoC5

Problemi correlati