2016-07-30 83 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