0

I am trying to send gmail using java. Body of mail is picked from properties file. I have added a property something like this.

new.emp.mail.reg= Welcome {userfirstname} <br> <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQcICAcKCwoLCg8OD.." width:"100px" height:"200px"> 

I got the mail, but there was no image in it. I can see the box of image(100x200) but image is not present. From img tag only width and height is rendered but not src attribute. How to solve this?

4 Answers4

0

I stumbled across same issue when i was sending some verification email's and i think that gmail doesn't support embedding inline images anymore, to prevent spam emails.

Try opening mail from some mail client like outlook or mailspring.

Your best bet to overcome this issue is to put image in the attachment and than link it via <img src="">

Next time instead of opening Stack Overflow thread try doing a bit of research yourself there is already tons of these questions out there :)

Gmail blocking small embedded inline images in email template

0

Try to change some elements in your code : src"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQcICAcKCwoLCg8OD.." to src="/9j/4AAQSkZJRgABAQAAAQcICAcKCwoLCg8OD.jpg"

Skykaza
  • 21
  • 5
0

use external links in your image source. e.g

<img src"https://unsplash.com/photos/xx69gBoiRXY"/>
0

I have added

<img src="cid:image"> in template. 

And added addInline method from Class (MimeMessageHelper)[https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/mail/javamail/MimeMessageHelper.html]. And it worked