I thought I would add my solution here in addition to the one mentioned above, since it uses both the auxiliary and temporary file paths if you are interested.
I changed the code here to insert a chart using a temporary path (they do the same using a range of cells in the book):
Sub createGraph(nameSheet As String, nameChart As String, nameFile As String) ThisWorkbook.Activate Worksheets(nameSheet).Activate With ThisWorkbook.Worksheets(nameSheet).ChartObjects(nameChart) .Activate .Chart.Export Environ$("temp") & "\" & nameFile & ".jpg", "JPG" End With End Sub
In the HTML put tag:
Call createGraph("Graphs", "Chart 1", "filename") TempFilePath = Environ$("temp") & "\" .Attachments.Add TempFilePath & "filename.jpg", olByValue, 0 .HTMLBody = .HTMLBody & "<img src='cid:filename.jpg'>"
Using "olByValue, 0", the attachment is added to position 0 and is not displayed as an attachment in the message.
source share