How to embed inline image in body of GMAIL

Hello, Anyone tried embedding image in the body of email using GMAIL. I need to know how an image be embedded in the body of email.

I don’t need as an attachment but want to embed in the body of mail. When I tried the image is always getting as an attachment.

Please help me with your inputs.

Hi, what is the activity you are using?

Please see detailed instructions and examples found throughout this forum post (assuming you send with SMTP): How to add the images in SMTP mail body

@Dave I went thru the above method but unfortunately it was not working so I had to log a request in forum for a solution.

@bcorrea yeah I used Send Mail Message integration activity inside a Gsuite application scope. I tried with content I’d method but still no luck.

Can anyone help me with an xaml???

Can you use Send SMTP activity instead of the Gsuite Send Mail Message? The forum post i linked above assumes you are using SMTP

The idea is to create the object of the Mail to be sent, but the activities here wont let you do that, you can do it with code, i will even create a custom activity for me :slight_smile: c# - Send inline image in email - Stack Overflow

1 Like

@bcorrea May I know where I have to use the custom code in Uipath to embed the image.
I have to check the data from google sheets and when I used Find Files and Folders Activity - It shows as error that the activity is under the Gsuite application scope. So since I’m under the Gsuite application scope I just used Send Mail Message in the same scope to send the email.

Plz help me with an xaml to proceed.

You need to use Invoke Code activity…

I’m doing the way I know to add inline images but not embedding the image in the body of the email, plz take a look and tell me where i’m doing wrong. Also if possible plz send me the corrected one.
WHEN I copied the code from stackoverflow to invoke code activity i got many errors and i seriously don’t know how to rectify that errors so i’m attaching the xaml of my version which i’m trying plz take a look on that project and send me the corrected one’s if there are any changes that you found. (4.4 KB)

You a re using the oldest gsuite package known to men :slight_smile: so i cannot open your project, still, i dont think you can use gsuite to do this… Also you can try like this when setting your attachments and your body:

oAttachment = new Attachment("test.png")
oAttachment.ContentId = "ImageContent1"
oBody = "<!DOCTYPE html><html><body><img src='cid:'"+oAttachment.ContentId+"'' alt='Smiley face' width='150' height='150'></body></html>"

Alright thanks for the update @bcorrea

Will try with the above solution and let you know on this. :sweat_smile:

@bcorrea I just tried and still getting it as an attachment. Plz take a look on the snapshot but i need it as an inline image.Untitled

I dont understand what is in this snapshot, but also, note that some mail client, might not support seeing the images in the body…

I attached the above image which has “Uipath Testing” as a body message and test.png as an attachment.

So @bcorrea you mean there is no other way to embed an image inside the body isn’t???
I make sure that
isBodyHTml is checked and though everything is done still the image is getting as an attachment or just showing an image icon in the body.

I had a biggest hope that I’ll get a solution in forum :frowning:

That is the way to do it… It will work using the way i showed you…

@bcorrea the cause Gmail must be generating the images differently which I’m not doing in the right way to embed it.

Thanks again @bruno for your assistance. :sweat_smile::clap:

There is no one across the forum who knows a solution to embed images in gmail???

Directly doing with UiPath is not possible but it can be done by integrating UiPath with Python
As Python’s email library gives the ease to create MIME objects that can send inline embed images.

For Code reference, one can refer to my personal UiPath Notes


Hi, For those who are looking to add inline attchments in GMAIL. This is a sample code that places 2 image files as Inline attachments in GMAIL body using UiPath.
GmailMailActivities.xaml (32.9 KB)

Did not work , in the code, HTML body is being read but that file is not been added in the code, can you please add that file