.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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
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,215,035
Messages
6,122,785
Members
449,095
Latest member
m_smith_solihull

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