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

tbakbradley

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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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