【发布时间】:2013-06-25 13:18:48
【问题描述】:
有没有办法让像 gmail 这样的在线邮件客户端显示内联发送的图像,即嵌入到邮件中?
在电子邮件中发送图像的最佳方式是什么?在线发送链接是最好的吗,因为大多数在线客户都支持?
【问题讨论】:
标签: java email grails email-attachments
有没有办法让像 gmail 这样的在线邮件客户端显示内联发送的图像,即嵌入到邮件中?
在电子邮件中发送图像的最佳方式是什么?在线发送链接是最好的吗,因为大多数在线客户都支持?
【问题讨论】:
标签: java email grails email-attachments
通常,如果图像在邮件中正确显示为inlined,则 Gmail 等邮件客户端会正确显示内联图像。在 grails 中 mail 插件的上下文中,我可以通过执行以下操作来实现 gmail 中的内联图像:
sendMail {
multipart true
// we send the image type regardless if the email client renders in html or plain text. If plain text
// jpg will be attached. Not a lot can be done since we do not know how the email client will render.
// if html, then image will be embedded in html and will not be attached and will be downloaded since image is not
// being loaded from external site.
if(filesToAttach){
filesToAttach.each{ file ->
inline file.tokenize(".").get(0), "image/jpeg", new ClassPathResource("/${file}", this.getClass())
}
}
to recipient
from from
subject subject
html view: view, model: [//my model]
}
通常,它取决于电子邮件客户端根据其设置呈现消息。但是,根据上述示例的实际实施已经显示出积极的结果。
【讨论】: