2013-06-25 35 views
0

有沒有像Gmail這樣的在線郵件客戶端顯示內嵌發送圖像的方式,即嵌入郵件中?Mail Inline圖像顯示錯誤?

在電子郵件中發送圖像的最佳方式是什麼?在線發送的鏈接是最好的,因爲大多數在線客戶端都支持這一點?

回答

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] 
     } 

一般而言,這取決於電子郵件客戶端上根據其設置來呈現信息。但是,根據上述例子的實際實施已經顯示出積極的結果。