PDA

View Full Version : Embedding an Image Using .HTMLBody and a Variable Name



basicintern
06-19-2014, 09:41 AM
Hi,

This is my first post on this forum and I sincerely appreciate any help I can get. I am trying to embed an image in an Outlook email.

This version of my code works perfectly:

.HTMLBody = "< img src='C:\ImageFolder\Image.png'>"

However, I am trying to make something like this happen:

Public Const image_path = “C:\ImageFolder\”
image_file = “Image.png”
image_name = image_path & image_file
image_name = Replace(image_name, Chr(34), Chr(39)) ‘replaces quotation marks wit apostrophes
.HTMLBody = "< img src=image_name>"

Outlook produces only a red X when I attempt to embed the image like this. I assume this means Outlook can’t find the image I am referencing. I am not sure if this is an error of trying to use a variable name in the .HTMLBody property or an error with my Replace() function or something else.

Thanks in advance for all of the help you can provide.

westconn1
06-19-2014, 02:20 PM
try
image_name = "'" & image_name & "'"
the replace line was not required as no quotes to replace, add the quotes to file name