Image Display in Outlook Signature
SolvedTonyLucky -
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:
- make sure the email is in HTML format. Which it is
- 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
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
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.
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.
Hello,
- in the code snippet you shared, what does the variable "signature" contain?
- the message "we cannot display the image" is displayed when and by what?
- what does the html body contain upon receiving the message?
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 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.
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.