Image Display in Outlook Signature

Solved
TonyLucky -  
 TonyLucky -

Hello everyone,

I am sending emails through Outlook from a VBA Excel application. Depending on the recipient of the email, a signature is added to the email. These signatures are saved in htm format in a folder.

This works very well, except when I add an image to the signature. I then get the message "we cannot display the image".

In my research, I've found two leads:

  1. make sure the email is in HTML format. Which it is
  2. uncheck, in the privacy management center, the option "do not automatically download..." Which it is

I haven't found any other leads, even on English-speaking sites. Here is the part of the code that sends the email:

With LeMail.CreateItem(olMailItem) .BodyFormat = olFormatHTML .SentOnBehalfOfName = Me.CBX_1.Text .To = Valeur_Cherchee_A .HTMLBody = "<p>" & texte1 & "</p><br><p>" & signature & "</p>" .Display 'allows to validate the email before sending it End With

If anyone has an idea, thank you very much in advance. Adding a logo to the signature makes the email more professional.

Tony


8 réponses

Anonymous user
 

Hello,

You add your logo directly in Outlook and then you just need to concatenate it in your code.

 Set LeMail = CreateObject("Outlook.Application") With LeMail.CreateItem(0) .BodyFormat = olFormatHTML .To = "***@***" .Subject = "Email Subject" .HTMLBody = .Body & "<p>" & texte1 & "</p><br>" .Display ' Allows to validate before sending End With 
0
TonyLucky
 

Good evening,

Thank you for your response.

I'm looking in Outlook, but I don't see where to save an image. I can add one to an email, but it's not automatic.

Depending on the recipients, I can have different signatures, with a specific image.

Could you be more specific and kindly indicate the procedure to follow? The same goes for the code part.

Thank you in advance.

0
Anonymous user
 

Here are the steps to insert a logo into a signature in Outlook, without using code:


---

1. Open the signature settings in Outlook

1. Open Outlook.


2. Click on File in the top left corner.


3. Go to Options.


4. In the window that opens, select the Mail tab in the left menu.


5. Click on the Signatures button in the Create or modify signatures for messages section.


---

2. Create or modify a signature

1. In the Signatures and Stationery window:

Click on New to create a new signature.

Give your signature a name (for example: MySignature).

2. In the signature editing area, add your text (name, position, contact information, etc.).


---

3. Add a logo or image

1. Place your cursor where you want to insert the image.


2. Click on the Image icon (small frame with a mountain).


3. Select the file of your logo or image from your computer.


4. Click Insert to add the image.


---

4. Adjust the image

1. Once the image is inserted, you can:

Resize the image: click on the corners to adjust its size.

Align the image: use the formatting options available in the editing toolbar.

---

5. Choose the emails to which to apply the signature

1. In the Choose default signature section:

New messages: select your signature to automatically add it to new emails.

Replies and forwards: choose whether to include the signature in your replies.

---

6. Save and use

1. Click OK to save your signature.


2. Close the settings and test by creating a new message to check that the logo appears correctly.


---

Tips

Supported formats: Use images in common formats like PNG, JPEG, or GIF.

Image size: Optimize the size of your logo (max. 200-300 pixels wide) to prevent the email from being heavy.

Verification: Send a test to your own address to check the display.


Thus, your logo will be included in all the emails you send with this signature.

0
TonyLucky > Anonymous user
 

Hello,

It's the simplest solution I had tried at first. Unfortunately, it doesn't work.

Thank you anyway for your suggestion.

1
yg_be Posted messages 23437 Registration date   Status Contributeur Last intervention   Ambassadeur 1 587
 

Hello,

  1. in the code snippet you shared, what does the variable "signature" contain?
  2. the message "we cannot display the image" is displayed when and by what?
  3. what does the html body contain upon receiving the message?
0
thev Posted messages 2007 Registration date   Status Membre Last intervention   723
 

Good evening,

It works very well, except if I add an image to the signature. I then get the message "we cannot display the image".

Indeed, the issue is that when you retrieve the link allowing access to the signature, the image address is only relative and does not allow it to be displayed. You need to use a function like this, converting the relative image address into an absolute address:

 Function Signature(signature_name As String, Optional account_name As String) As String Dim FSO As Object, TextStream As Object Dim file_name As String, signature_id As String, signature_id_Pct20 As String On Error Resume Next Set FSO = CreateObject("Scripting.FileSystemObject") If account_name <> Empty Then signature_id = signature_name & " (" & account_name & ")" _ Else signature_id = signature_name file_name = Environ("APPDATA") & "\Microsoft\Signatures\" & signature_id & ".htm" Set TextStream = FSO.OpenTextFile(file_name) If Err.Num = 0 Then Signature = TextStream.ReadAll signature_id_Pct20 = Replace(signature_id, " ", "%20") Signature = Replace(Signature, signature_id_Pct20, signature_id) 'replace relative image addresses with absolute addresses Signature = Replace(Signature, signature_id & "_files/", Environ("APPDATA") & "\Microsoft\Signatures\" & signature_id & "_files/") End If End Function 

0
yg_be Posted messages 23437 Registration date   Status Contributeur Last intervention   1 587
 

Will this absolute address be usable by the recipient of the message?

0
TonyLucky
 

Hello,

Thank you for your response.

Do the signatures need to be in the folder Environ("APPDATA") & "\Microsoft\Signatures\"? If so, this is what my computer shows: "C:\Users\Ordi1\AppData\Roaming"? If not, it would mean that the signatures can be in any folder, which would be more convenient for me...

I don't understand "my account". Does it refer to the email address or a password?

Thank you in advance for your clarification.

0
thev Posted messages 2007 Registration date   Status Membre Last intervention   723
 

Hello,

I advise you to display the contents of the directory:

C:\Users\Ordi1\AppData\Roaming\Microsoft\Signatures

to see how your signatures are stored: <signature_name>.htm. They may be associated with the email account or not.


0
TonyLucky
 

The folder C:\Users\Ordi1\AppData\Roaming\Microsoft\Signatures is empty.

So far, my signatures are stored in a folder I created, in htm format.

Do I have to use Environ("APPDATA") or can I keep my signatures in my current folder?

0
TonyLucky
 

I tested it and it works very well. Great. Thank you very much.

I kept my signatures in their current folder, but I save them in "web page, filtered" format.

Now, I have quite a bit of work to update my VBA!

Have a good day,

Tony

0