使用 Spring 在 Velocity 模板中包含图像
Including Image in Velocity Template using Spring
正在尝试将图像设置为徽标。 Html 放置在速度模板中。
ApplicationContext appContext = new FileSystemXmlApplicationContext();
Resource resource = appContext.getResource( "file:/D:/img/x.png" );
MimeMessage message = sender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper( message,
true,
"UTF-8" );
helper.addInline( "imageContent",
new File( resource.getURI() ));
//code to send the message
In .vm file,
<img src=\"cid:imageContent\"/>
电子邮件中未呈现图像。我在这里做错了什么?
如果我将图像作为附件发送,它会正确呈现。
您不能为您的系统图像添加任何绝对路径,相反您应该将您的图像放在某个 CDN 中并在您的模板中包含相同的 URL。然后只有它会呈现在您的电子邮件中。
已解决此问题。 <img src='cid:imageContent'/>
成功了。
正在尝试将图像设置为徽标。 Html 放置在速度模板中。
ApplicationContext appContext = new FileSystemXmlApplicationContext();
Resource resource = appContext.getResource( "file:/D:/img/x.png" );
MimeMessage message = sender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper( message,
true,
"UTF-8" );
helper.addInline( "imageContent",
new File( resource.getURI() ));
//code to send the message
In .vm file,
<img src=\"cid:imageContent\"/>
电子邮件中未呈现图像。我在这里做错了什么? 如果我将图像作为附件发送,它会正确呈现。
您不能为您的系统图像添加任何绝对路径,相反您应该将您的图像放在某个 CDN 中并在您的模板中包含相同的 URL。然后只有它会呈现在您的电子邮件中。
已解决此问题。 <img src='cid:imageContent'/>
成功了。