I would like to send a Excel chart in the body of an email (Outlook) (not as attachment) from VB, anyone know how to do this?
Solved:
Just to add a bit more detail to answer below
you'll need the following (could do with some improvement).
Sheets(2).ChartObjects(1).Chart.Export "C:\temp\Chart2.png"
....
.HTMLBody = "<html xmlns:o='urn:schemas-microsoft-com:office:office'" & _
"xmlns: x = 'urn:schemas-microsoft-com:office:excel'" & _
"xmlns='http://www.w3.org/TR/REC-html40'> " & _
"<head></head><body><img src='Chart2.png'></body></html>"
and
.Attachments.Add ("C:\temp\Chart2.png")
I thought I'd add my solution here in addition to the one above since it is using both a sub and a temporary file path, in case you are interested.
I changed the code from here to insert a chart using a temporary path (they do the same thing using a range of cells in the workbook):
In the HTML body put:
By using "olByValue, 0" the attachment is added at position 0 and not visible in the email as an attachment.
Seems like the best way is to export the chart:
And then add the image into your mail HTML body:
Confirmed by both technet and mrexcel