SMTP Mail message sends the broken image

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.

Your file path is backwards.

Change your \ to / like:

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

1 Like

It didn’t work for me :frowning:

1 Like

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?

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

Best Regards,
SP

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

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

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

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.

1 Like

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

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

@Santan_Barnwal, Thanks for the info :slight_smile:

Sorry mate, never heard of base64!

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

Cheers

1 Like

OK. Thanks for the reply :slight_smile:

@Namratha_Nayak ,did you got solution for it? same problem I have and i am unable to send/attach image in mail body.if anybody have solution can you please help. Thanks in advance

any solution u found?