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

tbakbradley

Board Regular
Joined
Sep 24, 2010
Messages
130
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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
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,215,561
Messages
6,125,538
Members
449,236
Latest member
Afua

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