How do I hide an attached image from the .htmlbody for mulitple emails?

lharr28

New Member
Joined
May 22, 2024
Messages
25
Office Version
  1. 365
Platform
  1. Windows
I'm trying to add a picture as a signature to emails that I am sending out to several individuals on a report and I don't want the image to show as an attachment on the email. I found code to hide the image as an attachment when it is sent, but when I do this, it doesn't send the email out to everyone on the report. Please see the code below:

With EItem

reportname = Range("A4")

.SentOnBehalfOfName = "clfsc@emory.edu"
.To = Range("D10")
.CC = Range("D26")
.BCC = Range("H26")
.Subject = reportname & " " & "(" & " " & Format(Date, "mm-d-yy") & ")"

'To break a single stmt into multiple lines use the underscore immediately preceded by a space and immediately followed by a line terminator like in the example below
.HTMLbody = "Dear Cardholder,<br/><br/>This is notice that you currently have a <b>past due</b> amount on your <b>Corporate Card</b>." _
& "Please review the attached report for details and notify your departmental liaison of your plan of action to resolve this issue within <b><u>two business days</b></u>." _
& "<br/><br/> <font color = red><b><i>If these items have already been processed, please advise and disregard this notice.</font color></b></i><br/><br/>Warm regards," _
& "<br><img src='C:\Users\lharr28\OneDrive - Emory University\Pictures\CLFSC Signature.jpg' 'height=200 width=300>"

.Display
.Attachments.Add PDFFile
'Add CLFSC signature as an attachment and to hide the image attachment (set the position argument to O) - when I do this it only does the cardholder selected and not the whole list
.Attachments.Add "C:\Users\lharr28\OneDrive - Emory University\Pictures\CLFSC Signature.jpg"
.Display

If DisplayEmail = False Then

.Send

End If
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
But you may instruct Outlook to insert a signature in your emails, with or without an image; so there is no need to do that "manually".
So my suggestion is:
-set in Outlook a signature
-then reuse the initial htmlbody and queue it to your message; something like
VBA Code:
.HTMLBody = "Your htm formatted email message" & .HTMLBody
Try...
 
Upvote 0
But you may instruct Outlook to insert a signature in your emails, with or without an image; so there is no need to do that "manually".
So my suggestion is:
-set in Outlook a signature
-then reuse the initial htmlbody and queue it to your message; something like
VBA Code:
.HTMLBody = "Your htm formatted email message" & .HTMLBody
Try...
Thanks! I will try this tomorrow.

The reason I did it this way is because I need to send the messages from a shared mailbox that has a different signature. Is there a way to do what you recommended but specify which signature to use as I have two different signatures? One signature for my personal account and another for the shared account.
 
Upvote 0
I am not an Outlook user... I would imagine that one option could be creating an second account with the desired signature, and use SentOnBehalfOfName to specify this second account of yours.
If you wish try with inline images, then you should use the "CID" attribute, as shown in the following instructions:

VBA Code:
'Create message with CID:
    myMsg = "<body>Good morning,  this is your friend Joe, <br>I wish to remember you the coming deadline <br><br>Your dearest friend<br>"
    myMsg = myMsg & " <img src=""cid:mySignaturePicture.jpg"" >"
    myMsg = myMsg & "<br>Bye bye </body>"
'
'other instructions
'
'Attach signature img
        .Attachments.Add "C:\Path\mySignaturePicture.jpg"             'full path and name
'
'other instructions
'
'Fill message
        .HTMLBody = myMsg
'
'other instructions
'

In this email, the image should be displayed after "Your dearest friend" and before "Bye bye".
But I am not sure that all the email clients will display the image
 
Upvote 0

Forum statistics

Threads
1,223,881
Messages
6,175,159
Members
452,615
Latest member
bogeys2birdies

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