Home » excel » excel – How can I embed an image from worksheet into Outlook email

excel – How can I embed an image from worksheet into Outlook email

Posted by: admin May 14, 2020 Leave a comment

Questions:

I am trying to embed a logo to the body of an Outlook email using VBA.

Currently my picture is stored in a shared drive called “Z”, and is being pasted to a new Outlook Message using the code below:

Dim EmailMessage As Object
Set EmailMessage = EmailClient.CreateItem(0)

With EmailMessage
    .To = ""
    .CC = ""
    .BCC = ""
    .Subject = "KEY123 Approval Needed for TM Products and Services"
    .Bodyformat = 2

    .HTMLBody = "<img src=""Z:\shield.png"">"
End With

How can I reference the path to point to a worksheet? I would like to use the image stored in Sheet 1 the image name is “shield”

What I would like: .HTML Body = "<img src=""Sheet1.Shapes("shield")"">"

How to&Answers:

You can simply copy the image from your worksheet, and paste it into the body of the email…

With EmailMessage
    .Display 'for testing purposes only
    .To = ""
    .CC = ""
    .BCC = ""
    .Subject = "KEY123 Approval Needed for TM Products and Services"
    .Bodyformat = 2
    Worksheets("Sheet1").Shapes("shield").Copy
    .GetInspector.WordEditor.Range.Paste
End With