I have added image path in ClassPathResource
in java. and My Images and velocity files are Stored in src/main/resources
this is my java Coding :
@Autowired
private JavaMailSender javamailsender;
@Autowired
private VelocityEngine velocityEngine;
MimeMessage msg = javamailsender.createMimeMessage();
MimeMessageHelper emailObject = new MimeMessageHelper(msg, true,"UTF-8");
emailObject.setTo("******");
emailObject.setFrom("******");
Object smileimage = new ClassPathResource("smiley.png");
File smfile = ((ClassPathResource) smileimage).getFile();
Map model = new HashMap();
model.put("smfile", smfile);
StringBuffer content = new StringBuffer();
content.append(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine,
"/velocity/Demo.vm", "UTF-8", model));
Multipart mp = new MimeMultipart("alternative");
BodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(content.toString(), "text/html");
mp.addBodyPart(htmlPart);
msg.setContent(mp);
javamailsender.send(emailObject.getMimeMessage());
This is my Velocity file:
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<img src='$smfile' alt="birthay img" with="130" height="130" >
</body>
</html>
Email receive my local System is Perfect....but Other System mail receive images are not Found..