cancel
Showing results for 
Search instead for 
Did you mean: 

Inline image in Outlook Email body

Erika_Papp
Level 4

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.

 

<html>
<body>
<p>Test</p><img src='data&colon;image/jpg;charset=utf-8;base64,QzpcT0cwMDFfRGFpbHkgU2FsZXMgUmVwb3J0XDIwMjQtMDUtMDhcUGFweXJ1cyBCRS5qcGc=' />
</body>
</html>
 
 
 
<html>
<body>
<p>Test</p><img src="C:\test.jpg">
</body>
</html>

 

 

1 BEST ANSWER

Helpful Answers

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"

rsrivastava2_0-1715594509044.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 - 

rsrivastava2_1-1715594694714.png

 

WeitghtRPAMatey

View answer in original post

6 REPLIES 6

durgesh.sharma2
Level 3

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.

durgeshsharma2_0-1715335734150.png

I hope this will help you.

Bring 2 data items like this 

Mohamad_747_0-1715546075479.png

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 : 

Mohamad_747_1-1715546221713.png

Replace([Mail],"***PATH_TO_IMG***",[Path to img])

I hope this will help you.

Regards.

 

Hi, 

Thank you for the answer. Unfortunately the sent email look like this after the recipient received it: 

Erika_Papp_0-1715591505745.png

 

 

 

Hi,

Can you try with another image just to see if the issue is related to the image or not  ?

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"

rsrivastava2_0-1715594509044.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 - 

rsrivastava2_1-1715594694714.png

 

WeitghtRPAMatey

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

SayeedBinAbdullah_0-1732421582230.png

 

SayeedBinAbdullah_1-1732419479560.png

SayeedBinAbdullah_2-1732419548410.png

"# 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,

SayeedBinAbdullah_3-1732419733163.png

SayeedBinAbdullah_4-1732419799463.png

"@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

SayeedBinAbdullah_5-1732419897244.pngSayeedBinAbdullah_6-1732420610145.png

Sayeed Bin Abdullah

Senior Consultant - Automation Developer
Wonderbotz