【问题标题】:Adding inline image in mail body using Mail Gem使用 Mail Gem 在邮件正文中添加内联图像
【发布时间】:2023-03-29 06:15:01
【问题描述】:

我正在使用Mail Gem 发送电子邮件。我正在尝试使用如下内联图像标签发送.PNG 文件

record_stream << "<br /> <p>Jeff added an image today.</p>"
  .concat( "<img src="pngImagePath" /> " )

mail = Mail.new do
  from    'from@gmail.com'
  to      'some@gmail.com'
  subject "Automated Report
  html_part do
    body "<i>This is an automated email.  All data in this email was generated automatically.</i>
          #{record_stream}
        "
  end
end #### End of mailer

但是当我检查我的 gmail 时,record_stream 没有出现。既不是字符串也不是图像。我想在电子邮件正文中显示两者。任何帮助将不胜感激。谢谢

【问题讨论】:

    标签: ruby-on-rails ruby rubygems mail-gem


    【解决方案1】:

    首先,图片路径应该有图片的 url 链接,而不是相对路径(因为电子邮件无法访问您服务器中的图片)。

    您可以尝试直接在html_part body中添加图片看看是否有效

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2020-03-14
      • 1970-01-01
      • 2013-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-08
      • 2016-02-13
      相关资源
      最近更新 更多