VBA: Embedding a Picture in an Outlook Email

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
21,582
Office Version
  1. 365
Platform
  1. Windows
Is it at all possible to embed a picture in an email? I've tried...

Code:
.HtmlBody = " < img src=""C:/Users/Domenic/Desktop/Sample.png"" > "

However, while the picture gets inserted in the email, it's not actually embedded. As a result, when the recipient receives the email, the image is not displayed.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi,

Probably this may get the desired objective.

"<img src=C:\Users\user\Pictures\50527.jpg' height=480 width=360>"
 
Last edited:
Upvote 0
Hi,

Probably this may get the desired objective.

HTMLBody = "< html>< p>This is a picture.< /p>" & _
"< img src=C:\Users\user\Pictures\50527.jpg' height=480 width=480>"

Thanks sanits591. I tried it but unfortunately the image is still linked instead of embedded. So, if I send an email to someone, the image is not displayed. If I send the email to myself, the image is displayed, since it's linking to the file on my system.

Any other ideas?

P.S. By the way, the system interprets "<" as the start of HTML code. To escape it, insert a space after each occurrence of "<".
 
Upvote 0
This code runs perfectly as an embedded one in my system, yes it could be true, that this may not be displaying on other system, however i have not given it a try to check on other system.

Another, a wild guess, Can we look for uploading the desired image on the internet and then insert the link of that uploaded image in the code?, probably this shall avoid the linking of image to your system.
 
Last edited:
Upvote 0
A wild guess, Can we look for uploading the desired image on the internet and then insert the link of that uploaded image in the code?, probably this shall avoid the linking of image to your system.

I was hoping to avoid doing it that way. :) I know that an image can manually be copied from within Excel and pasted into an email in Outlook with the image being embedded. So, hopefully, there must be some code available that would do the same. :)

Thanks sanits591!
 
Upvote 0
Thanks for updation!, but now i have checked on another system also, the image is well embedded in the outlook mail (2010) and not as an attachment with the same VBA code.

The source code on another system of the outlook mail has got the code, which shows there is no linkage of image file with my system.

Kindly provide any suggestions on this.

Thanks!
 
Last edited:
Upvote 0
Thanks for updation!, but now i have checked on another system also, the image is well embedded in the outlook mail (2010) and not as an attachment with the same VBA code.

The source code on another system of the outlook mail has got the following code (other code is trimmed) as mentioned, which shows there is no linkage of image file with my system.

Kindly provide any suggestions on this.

Code:
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p>This is a picture.<o:p></o:p></p><p class=MsoNormal><img width=480 height=480 id="_x0000_i1025" src="cid:image003.jpg@01CCCCD0.E2FC4830"><o:p></o:p></p></div>


Thanks!

Thanks for your continued help with this matter. Much appreciated.

How would I implement the above code?
 
Upvote 0
Domenic

I think this can be done by attaching the picture then referring to the attached picture in the HTML of the body of the message.

Or by setting particular properties of the attachment.

I suppose that kind of defeats the point though if you want to do it without attaching anything.
 
Upvote 0

Forum statistics

Threads
1,215,087
Messages
6,123,046
Members
449,092
Latest member
ikke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top