有没有办法让像gmail这样的在线邮件客户端显示内联发送的图像,即嵌入邮件中?
在电子邮件中发送图片的最佳方式是什么?在线发送最好的链接,因为大多数在线客户支持这个吗?
答案 0 :(得分:0)
通常情况下,如果图片在邮件中正确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]
}
通常,它取决于电子邮件客户端根据其设置呈现消息。然而,根据上述示例的实际实现已经显示出积极的结果。