SMTP Mail message sends the broken image

uiautomation
email
uipath

#1

Could anyone please tell me where I am going wrong.

I am trying to automate, automatic email sending on Employee birthday. Following is what I am doing

  1. Reading the excel sheet and retrieving the employee info.
  2. Accessing the local folder and picking random image from it and embedding it between the content.
  3. Sending the email using SMTP.

In step 2), I am storing the image url inside the variable “randomImage”. When I print this url, I am getting the proper path like, “C:\Users\Namratha\Documents\UiPath\BirthdayMailAutomation\Docs\Birthday3.jpg”

But when I used this inside the html content, it gives the broken image.
Please find the attached html content which I am using for SMTP mail message. IsHtmlBody is also checked.


#2

Your file path is backwards.

Change your \ to / like:

“C:/Users/Namratha/Documents/UiPath/BirthdayMailAutomation/Docs/Birthday3.jpg”


#3

It didn’t work for me :frowning:


#4

Are you sending the email externally? or internally?

Is your email configured on a local intranet?

Have you tried not using the variable and putting the manually and seeing if it appears?


#5

Hi @Namratha_Nayak,
Can you try using relative path instead of absolute one ?
Change randomImage value to “Docs\Birthday3.jpg”

Best Regards,
SP


#6

@SantoshPothina, Tries using Relative. But I am getting broken image here.

Instead of using the variable, for testin purpose, hardcoded one image inside the img tag. But I am getting broken image in this case.


#7

@CBlanchard,

Yes it is configured on a local intranet.

Tried using both manual and local.

To send any image, does it need to be hosted somewhere? Can’t we send image stored locally?


#8

Can you please share xaml file here (If you can)?


#9

You can’t directly embed image in the body of the html using <img src=""/> because image is saved in your local PC.

you have to use some .Net Code to embed images or you have to host image somewhere on the internet then you can give URL of the hosted images in the <img src=""/>. This will work.

you can host images in google drive or any web server.


#10

@Namratha_Nayak You should be able to send an image locally if your email is hosted on a local intranet.

If you can, share the .xaml.


#11

@CBIanchard, Sorry for the inconvenience. I thought it’s local intranet, but it’s not.

I heard that there are 2 ways to achieve this:

  1. The image should be hosted.
  2. The image needs to be converted to base64. Any idea how to achieve this second one?

#12

@Santan_Barnwal, Thanks for the info :slight_smile:


#13

Sorry mate, never heard of base64!

Yes, the image will need to be hosted as @Santan_Barnwal stated if its not local.

Cheers


#14

OK. Thanks for the reply :slight_smile: