0

视图中的内容未显示。仅发送附件。帮助将不胜感激!

def send
 @subject = "Status of PIS App"
 @recipients = "ssg@gmail.com"
 @from = APP_CONFIG[:email]
 @sent_on = Time.now
 #@content_type = "text/html"
 content_type = "multipart/alternative"

 attachment :filename => "Report.html",:content_type => "text/html",
  :body => File.read("/home/shreyas/repos/mysorepoc/app/models/new1.html")
end
4

1 回答 1

1

使用附件时,需要单独指定文本部分:

def send
  @subject = "Status of PIS App"
  @recipients = "ssg@gmail.com"
  @from = APP_CONFIG[:email]
  @sent_on = Time.now
  #@content_type = "text/html"
  content_type = "multipart/mixed"

  part :content_type => "text/plain", :body => "contents of body"

  attachment :filename => "Report.html",:content_type => "text/html", :body => File.read("/home/shreyas/repos/mysorepoc/app/models/new1.html")
end

而且您可能希望将邮件作为多部分/混合发送,而不是作为多部分/替代发送(除非附件确实是文本部分的替代表示)。

于 2010-08-03T16:54:01.723 回答