PP8
PP8

Reputation: 197

How can I embed an image from worksheet into Outlook email

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")"">"

Upvotes: 1

Views: 127

Answers (1)

Domenic
Domenic

Reputation: 8104

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

Upvotes: 2

Related Questions