.HTMLBody VBA code to attach a picture (PNG)

STIMPSOND

New Member
Joined
Mar 14, 2019
Messages
3
Hi,

I’m trying to attach a picture/PNG file to An email via VBAcode using .HTMLBody but want to set the location of picture not within theHTML statement:

Currently:
.HTMLBODY = "<HTML>******><imgalign=baseline border=0 hspace=0 src='C:\Users\ documents\Reporting\MacroTest\New folder\Comms.PNG'</BODY></HTML>"

I’d like:

Comms = 'C:\Users\Documents\Reporting\Macro Test\Newfolder\Comms.PNG'

.HTMLBODY = "<HTML>******><imgalign=baseline border=0 hspace=0 src=’Comms’ </BODY></HTML>"

It isn’t working and I assume I’m missing somethingstupid. Any help will be appreciated

Thanks

 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Welcome to the message board!

HTML links can't have spaces in them. Replace the spaces with "%20" and try again. Also, you should upload the pic to a web server so that the recipient can see the same pic. I'm sure there's a way to send the image as an attachment but I don't know how to display that in the message.
 
Upvote 0
Hi all,

for some reason my post didn't post correctly.

I'd like to insert a picture into outlook and obviously need to have outlook as HTML which I've done. I've also managed to get the picture to copy into the body of excel so all good there. What I'm trying to do is make it so if a user wants to update the picture as long as they save it in the same directory as wherever the excel workbook is then it works. e.g. Set Comms = ThisWorkbook.Path & "" & Comms and then within HTMLBody i want to refer to Comms.

Thanks
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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