I am trying to insert a hosted image to the body of my message. Here is what i have done so far:
Private Sub inspectors_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles inspectors.NewInspector
Dim mailItem As Outlook.MailItem = TryCast(Inspector.CurrentItem, Outlook.MailItem)
If Not (mailItem Is Nothing) Then
If mailItem.EntryID Is Nothing Then
mailItem.Subject = "Test"
mailItem.Body = mailItem.Body + "<html><img src='http://example.com/pixel.php?to=" + mailItem.To + "></html>"
End If
End If
End Sub
The above inserts doesnt actually embed the image, it just adds the line:
<html><img src='http://example.com/pixel.php?to=" + mailItem.To + "></html>
To my my email body.
How can i get it embedded?
Per my comment you are using MailItem.Body which is for plain text. Switch to HTMLBody
Private Sub inspectors_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles inspectors.NewInspector
Dim mailItem As Outlook.MailItem = TryCast(Inspector.CurrentItem, Outlook.MailItem)
If Not (mailItem Is Nothing) Then
If mailItem.EntryID Is Nothing Then
mailItem.Subject = "Test"
mailItem.HTMLBody = mailItem.HTMLBody + "<html><img src='http://example.com/pixel.php?to=" + mailItem.To + "></html>"
End If
End If
End Sub