【问题标题】:Generating html with CFSaveContent, images don't display使用 CFSaveContent 生成 html,图像不显示
【发布时间】:2016-07-30 00:42:10
【问题描述】:

我正在尝试使用 cfsavecontent 发送一个 html 页面(带有 CSS 格式)。但是,当我通过cfmail 发送变量时,一切正常,除了图像。

<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@hotmail.com" to="email@gmail.com" subject="test email" type="html">
    test:
    <br /><br /><br />
    #YourImg#
    <br /><br /><br />
</cfmail>

这显示了用 CSS 格式化的 HTML 表格,但图像看起来好像丢失了。谁能解释一下为什么?

【问题讨论】:

  • 当您想在 HTML 电子邮件中嵌入图像时,您只需提供绝对 URL。所以src 属性看起来像http://somedomain.com/imgs/image/jpg 而不是/imgs/image.jpg

标签: image coldfusion cfmail


【解决方案1】:

&lt;cfsavecontent&gt; 仅将标签之间生成的标记保存到字符串中。你可以&lt;cfdump var="#YourImg#"&gt;自己看看。

&lt;cfdocument&gt;可以截取图片,但是转换成pdf文件。文档@https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-d-e/cfdocument.html

要将文件附加到电子邮件,请查看&lt;cfmailparam&gt;@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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-06
    • 1970-01-01
    相关资源
    最近更新 更多