2016-07-30 82 views
2

我正嘗試使用cfsavecontent發送html頁面(使用CSS格式)。但是,當我通過cfmail發送變量時,除了圖像以外,一切正常。使用CFSaveContent生成html,圖像不顯示

<cfsavecontent variable="YourImg"> 
    <table class="table_css"> 
     <tr> 
      <td> 
       <p> your image is this:</p> 
       <img src="/imgs/image.jpg"> 
      </td> 
     </tr> 
    </table> 
</cfsavecontent> 


<cfmail from="[email protected]" to="[email protected]" subject="test email" type="html"> 
    test: 
    <br /><br /><br /> 
    #YourImg# 
    <br /><br /><br /> 
</cfmail> 

這顯示了HTML表格,使用CSS格式化,但圖像看起來像缺少。有人可以解釋爲什麼嗎?

+1

當您要嵌入HTML電子郵件的圖像,你可以簡單地提供絕對URL。所以'src'屬性看起來像'http:// somedomain.com/imgs/image/jpg'而不是'/ imgs/image.jpg' –

回答

1

<cfsavecontent>只將標記之間生成的標記保存到字符串中。你可以<cfdump var="#YourImg#">,看看你自己。

<cfdocument>可以捕捉圖像,但成爲一個pdf文件。督@https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-d-e/cfdocument.html

要將文件附加到電子郵件,請看<cfmailparam> @https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-m-o/cfmailparam.html

實施例2:此僅查看例如在 HTML消息的主體來顯示圖像。

<cfmail type="HTML" 
    to = "#form.mailto#" 
    from = "#form.mailFrom#" 
    subject = "Sample inline image"> 
    <cfmailparam file="C:\Inetpub\wwwroot\web.gif" 
     disposition="inline" 
     contentID="image1"> 
<p>There should be an image here</p> 
<img src="cid:image1"> 
<p>After the picture</p> 
</cfmail> 
+0

謝謝,讓我試試看.. – CMP