Embedded Picture in Excel File- Need it to show on Email with HTMLBody

tbakbradley

Board Regular
Joined
Sep 24, 2010
Messages
136
I currently have a Macro that will Send an email Automatically in Outlook. I use .HTMLBody. The Email needs to include a picture after the text. I have it working with <img src...=""> pointing to a jpeg on a Server. However, it's slow as it takes several seconds for the picture to open once you open the email, after you see it connecting to the server. That won't do for us because we've noticed that we can open the Attachment from the email before that picture appears.

If I Insert that picture directly into Excel, and it's Defined Name is Picture 1....how can I call that via .HTMLBody so that it's inserted into the email? I'm thinking that would load much quicker than the jpeg located on the Server.


I'd like to insert the Picture 1 that I embedded directly into Excel into the Email at this spot. Is that doable?
 
Last edited:

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try something like this...

Code:
Sub test()

    Dim olApp As Object
    Dim olMItem As Object
    
    Set olApp = CreateObject("Outlook.Application")
    Set olMItem = olApp.createitem(0)
    
    Worksheets("Sheet1").Shapes("Picture 1").Copy
    
    With olMItem
        .to = "johnsmith@abc.com"
        .Subject = "Misc"
        .body = "Your text here..."
        .Display
        With .GetInspector.WordEditor
            .Application.Selection.EndKey Unit:=6 'to go to the end of email body
            .Application.Selection.TypeParagraph 'new line
            .Application.Selection.TypeParagraph 'new line
            .Application.Selection.Paste
        End With
        'Send
    End With
    
    Set olMItem = Nothing
    Set olApp = Nothing
    
End Sub

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top