3

I am trying to write a Java program where I need to send an image to Gmail. I am sending the image as an embedded object.

<img src="data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAACcAAAAsCAYAAADmZKH2AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABISURBVFhH7c4hAQAgEAAxEhGGZN8YOkwhTsxvnT33V+VUOVVOlVPlVDlVTpVT5VQ5VU6VU+VUOVVOlVPlVDlVTpVT5dTHubkPuMrNUFKjQWUAAAAASUVORK5CYII=">

Other mail service providers are showing it fine, but Gmail specifically is removing it, so it is not visible in the message.

How can I make it visible in Gmail as well as the other mail service providers?

nostalgk
  • 229
  • 2
  • 20
Bogl
  • 125
  • 2
  • 11
  • Possible duplicate of https://stackoverflow.com/questions/8580355/can-you-send-images-in-datauri-format-to-gmail. – VGR Jul 16 '18 at 21:13

2 Answers2

0

Place the image in a publicly accessible server and give the url for src attribute instead of dataUrl.

Johna
  • 1,836
  • 2
  • 18
  • 29
0

It is not possible in Gmail, outlook etc. They ignore base64 images. For further information follow the link at below.

https://www.campaignmonitor.com/blog/email-marketing/2013/02/embedded-images-in-html-email/

There is an alternative way for doing this. Embed images in the email using the cid method. (Basically including the image as an attachment, and then embedding it).

https://www.campaignmonitor.com/blog/how-to/2008/08/embedding-images-revisited/

Anisuzzaman Babla
  • 6,510
  • 7
  • 36
  • 53