Reputation: 835
I have tried to embed a base64 type and not working. The image not displayed in the email.
string imreBase64DataHeader = LogoFromByteArray(_org.O_Logo);
image = "<img src='data:image/png;base64," + imreBase64DataHeader + "' alt='img' />";
body += string.Format("<div>{0}</div> <br/><br/>", image);
Note: I have a pdf attachment in the email already.
The logo is saved in the db as byte array and I need to add this in the email signature.
Thank you in advance for the help.
Upvotes: 0
Views: 1142
Reputation: 49405
Base64 images are not supported in Outlook for desktop. Instead, you need to save the image on the disk and then attach it to the email. Then in the message body you can refer to such attachments by using the cid:
prefix:
.Attachments.Add "C:\Users\JoeSchmo\Pictures\ImageName.jpg", olByValue, 0
.HTMLBody = "<BODY><IMG src=""cid:ImageName.jpg"" width=200> </BODY>"
You may also consider setting the following properties on the attachment:
Const PR_ATTACH_MIME_TAG = "http://schemas.microsoft.com/mapi/proptag/0x370E001E"
Const PR_ATTACH_CONTENT_ID = "http://schemas.microsoft.com/mapi/proptag/0x3712001E"
Const PR_ATTACHMENT_HIDDEN = "http://schemas.microsoft.com/mapi/proptag/0x7FFE000B"
Set oPA = Attachment.PropertyAccessor
oPA.SetProperty PR_ATTACH_MIME_TAG, "image/jpeg"
oPA.SetProperty PR_ATTACH_CONTENT_ID, "cidName"
oPA.SetProperty PR_ATTACHMENT_HIDDEN, True
Read more about this in the Embed Images in New Messages using a Macro article.
Upvotes: 1
Reputation: 741
You have to first convert byte array to base64encoded string.
Try this code.
string imageTag = "<img id ='Icon' src='data:image/*;base64,"+(Convert.ToBase64String(imageByte))+"' >";
Also if you are using outlook as your email client you might need to download the image in the email preview.
Upvotes: 0