简体   繁体   English

邮件内嵌图像显示错误?

[英]Mail Inline Images display Error?

Is there a way that online mail clients like gmail display images that are sent inline, ie, embedded in the mail? 在线邮件客户端(例如gmail)是否可以显示以嵌入式方式发送(即嵌入在邮件中)的图像?

What is the best way to send images in email? 用电子邮件发送图像的最佳方法是什么? Is sending online the link the best, because most online clients support that? 在线发送链接是最好的,因为大多数在线客户端都支持吗?

Normally, mail clients like Gmail display the inline image appropriately if the image is properly inlined in the mail. 通常,如果在邮件中正确inlined图像,则Gmail等邮件客户端会适当显示内嵌图像。 In context to mail plugin in grails, I was able to achieve the inline image in gmail by doing something like: 在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]
        }

Generally, it depends on the email client to render the message according to its setup. 通常,它取决于电子邮件客户端根据其设置呈现消息。 However, the actual implementation according to the above example has shown positive results. 但是,根据以上示例的实际实施已显示出积极的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM