08-05-24 03:57 PM
Hi,
I am trying to add image to the Outlook HTML email body but it always appears like a red cross.
Anyone has any solution for this?
Thank you.
Answered! Go to Answer.
13-05-24 11:05 AM
Hi Erika,
Before the solution, what you must know is, when you include something like <img src="C:\Users\Rohit\Desktop\email\logo.png" /> Your are essential asking that email to fetch the image from the local system and that may not be necessarily available on the recipient's device.
What you need to do is, instead of above path just do <img src="logo.png" /> and then include a attachment collection where column Path includes all the images in email body, like "C:\Users\Rohit\Desktop\email\logo.png"
These attachments that are referenced in IMG tag in email body will not show as attachment but will appear in body like you intend to.
Example -
10-05-24 11:10 AM
Hi Erika,
Please try the solution in the attached screenshot as after adding some code to the existing VBO (Email - POP3/ SMTP) it will work perfectly and attach the image in the body of the email as you wanted.
I hope this will help you.
12-05-24 09:37 PM - edited 12-05-24 09:38 PM
Bring 2 data items like this
Inside the mail data item put :
<style>
table {font-family: Verdana; font-size: 10pt; width: 100%}
td {border: 1px solid gray; border-collapse: collapse; padding: 5px}
</style>
<div style="font-family: Verdana; font-size: 10pt">
<p>You can find below the image:</p>
<br>
<img src="***PATH_TO_IMG***" alt="Image Description" width="1000">
Notice : you can modify the width if you want.
Inside the Path to img you put the path to your image.
Inside your vbo you put this expression :
Replace([Mail],"***PATH_TO_IMG***",[Path to img])
I hope this will help you.
Regards.
13-05-24 10:12 AM
Hi,
Thank you for the answer. Unfortunately the sent email look like this after the recipient received it:
13-05-24 10:35 AM
Hi,
Can you try with another image just to see if the issue is related to the image or not ?
13-05-24 11:05 AM
Hi Erika,
Before the solution, what you must know is, when you include something like <img src="C:\Users\Rohit\Desktop\email\logo.png" /> Your are essential asking that email to fetch the image from the local system and that may not be necessarily available on the recipient's device.
What you need to do is, instead of above path just do <img src="logo.png" /> and then include a attachment collection where column Path includes all the images in email body, like "C:\Users\Rohit\Desktop\email\logo.png"
These attachments that are referenced in IMG tag in email body will not show as attachment but will appear in body like you intend to.
Example -
4 weeks ago - last edited 4 weeks ago
Hi @Erika_Papp
Below is the working solution to attach multiple images in the body of an outlook email using PowerShell script and batch file,
Step1:- Create a PowerShell script using with the following lines of code and save it as Powershellscript.ps1
"# Create a new mail item
$mail = $Outlook.CreateItem(0)"&NewLine()&"
# Set the mail item properties
$mail.Subject = "&[Double]&"Email with Multiple Images"&[Double]&NewLine()&"
$mail.To = "&[Double]&"recipient@example.com"&[Double]&NewLine()&"
$mail.BodyFormat = 2 # 2 means HTML format"&NewLine()&"
# Create the HTML body with image placeholders
$body = @"&[Double]&NewLine()&"
<html>"&NewLine()&"
<body>"&NewLine()&"
<p>Here are some images:</p>"&NewLine()&"
<p>"&NewLine()&"
<img src='cid:image1'><br/>"&NewLine()&"
<img src='cid:image2'><br/>"&NewLine()&"
<img src='cid:image3'><br/>"&NewLine()&"
</p>"&NewLine()&"
</body>"&NewLine()&"
</html>"&NewLine()&"
"&[Double]&"@"&NewLine()&"
$mail.HTMLBody = $body"&NewLine()&"
# Add images as attachments
$image1 = $mail.Attachments.Add("&[Double]&"C:\path\to\image1.jpg"&[Double]&")"&NewLine()&"
$image1.PropertyAccessor.SetProperty("&[Double]&"http://schemas.microsoft.com/mapi/proptag/0x3712001F"&[Double]&", "&[Double]&"image1"&[Double]&")"&NewLine()&"
$image2 = $mail.Attachments.Add("&[Double]&"C:\path\to\image2.jpg"&[Double]&")"&NewLine()&"
$image2.PropertyAccessor.SetProperty("&[Double]&"http://schemas.microsoft.com/mapi/proptag/0x3712001F"&[Double]&", "&[Double]&"image2"&[Double]&")"&NewLine()&"
$image3 = $mail.Attachments.Add("&[Double]&"C:\path\to\image3.jpg"&[Double]&")"&NewLine()&"
$image3.PropertyAccessor.SetProperty("&[Double]&"http://schemas.microsoft.com/mapi/proptag/0x3712001F"&[Double]&", "&[Double]&"image3"&[Double]&")"&NewLine()&"
# Send the email
$mail.Send()"
Step2 :- Now create a .bat file with the following command in it,
"@echo off"&NewLine()&"
powershell -NoProfile -ExecutionPolicy Bypass -File "&[Double]&"C:\path\to\your\Powershellscript.ps1"&[Double]&NewLine()&"
pause"
Step 3 :- To send email run the batch script using Utility - Environment -> Start Process
Sayeed Bin Abdullah