0

The below code with .PNG file referenced, works for me. However, while the .PNG gets inserted in the email, it's not actually embedded. As a result, when the recipient receives the email, the image is not displayed.

Sub Mail_workbook_Outlook_1()

relativepath1 = ThisWorkbook.Path & Application.PathSeparator & "Signature99" & ".png"

'Create a new email message
Set OutlookMessage = OutlookApp.CreateItem(0)

On Error Resume Next
With OutlookMessage
.To = Prime_Email
.cc = cc1
.BCC = ""
.Subject = "Volume - " & " " & str2 & "(" & Subject & ")"
.HTMLBody = RangetoHTML(Range("E2:N16")) & "<img src ='" & relativepath1 & "'>"
.send
'.Display
End With
On Error GoTo 0
Set OutlookMessage = Nothing
Set OutlookApp = Nothing
End Sub
  • First attach the image to your email with `.Attachments.Add "c:\users\domenic\desktop\sample.jpg"`, and then embed it within your email with `""`. Change the path and filename accordingly. – Domenic Jul 01 '21 at 22:54

1 Answers1

0

First attach the image to your email, and then embed it within your email...

Sub Mail_workbook_Outlook_1()

Dim relativepath1 As String
relativepath1 = ThisWorkbook.Path & Application.PathSeparator

Dim filename As String
filename = "Signature99.png"

'Create a new email message
Set OutlookMessage = OutlookApp.CreateItem(0)

On Error Resume Next
With OutlookMessage
.To = Prime_Email
.CC = cc1
.BCC = ""
.Subject = "Volume - " & " " & str2 & "(" & Subject & ")"
.Attachments.Add relativepath1 & filename
.HTMLBody = RangetoHTML(Range("E2:N16")) & "<img src ='cid:" & filename & "'>"
.Send
'.Display
End With
On Error GoTo 0
Set OutlookMessage = Nothing
Set OutlookApp = Nothing
End Sub
Domenic
  • 7,844
  • 2
  • 9
  • 17