Embedded Inline Image Issue

tjiddy89

New Member
Joined
Mar 7, 2018
Messages
20
Hello all! Trying to generate an automated email with Gmail that includes a screenshot of a previously generated image but it's only showing the alternate text as defined in .HTMLbody. I've confirmed the HTML code works in a localized file but it's not showing in the email. Any help would be greatly appreciated!

Code:
 Enter your GMail credentials here and whoever you would like to send this report to.
    email = ""
    pass = ""
    msgTO = email
    msgCC = ""
    msgBCC = ""
    
    ' Had to remove the <> to avoid the actual document being counted as a live HTML tag.
    body = "img src='C:\Users\john.doe\Exports\agentDev.png' alt='Agent Development Chart'"
    
    Set NewMail = CreateObject("CDO.Message")
    Set mailConfig = CreateObject("CDO.Configuration")
    
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    ActiveWorkbook.Sheets.Copy
    ActiveWorkbook.Worksheets(1).Shapes("send").Delete
    ActiveWorkbook.Worksheets(1).Shapes("update").Delete
    ActiveWorkbook.Worksheets(1).Shapes("close").Delete
    ActiveWorkbook.SaveAs Filename:="agent.xlsx", FileFormat:=51
    ActiveWorkbook.Close
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    
    mailConfig.Load -1
    Set fields = mailConfig.fields
    
    With NewMail
        .Subject = ""
        .From = email
        .To = msgTO
        .CC = msgCC
        .BCC = msgBCC
        .htmlbody = body
        .AddAttachment "agent.xlsx"
    End With
    
    msConfigURL = "http://schemas.microsoft.com/cdo/configuration"
    With fields
        .Item(msConfigURL & "/smtpusessl") = True
        .Item(msConfigURL & "/smtpauthenticate") = 1
        .Item(msConfigURL & "/smtpserver") = "smtp.gmail.com"
        .Item(msConfigURL & "/smtpserverport") = 465
        .Item(msConfigURL & "/sendusing") = 2
        .Item(msConfigURL & "/sendusername") = email
        .Item(msConfigURL & "/sendpassword") = pass
        .update
    End With
    NewMail.Configuration = mailConfig
    NewMail.Send
    Kill "agent.xlsx"
 
Last edited:

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
I've also tried the below code to no success.
Code:
img src='cid:agentDev.png'" & "width='100%'...

Full-disclosure: No idea what cid does, and I could not find any explanation online either.
 
Upvote 0
BUMP

To reword this, how can I insert inline images into emails via Gmail? I've been trying to figure this out myself for two days and it's driving me nuts lol
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

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