【发布时间】:2014-07-29 19:17:31
【问题描述】:
我正在尝试让 ActionMailer 交付我生成的 CSV:
@csv= CSV.generate(force_quotes: true) do |csv|
::CourseExportGenerator.load_template csv, sections, standard, registration
end
@filename = "my_sweet_filename.csv"
EnterpriseMailer.send_report(@csv, @filename).deliver
然后我的 EnterpriseMailer.rb 文件看起来像这样:
def send_report report, filename
attachments["#{filename}"] = {data: report, encoding: 'base64'}
mail to: 'trip@triptrip.com', subject: "Your large CSV file!"
end
电子邮件的主题正确,但没有我的实际内容(只是一些简单的占位符文本)。附加的文件标题为“noname”,打开时显示为:
This is a multi-part message in MIME format...
----
我知道它传送的文件大约有 2 到 3 兆字节,并且有超过 8,000 行。
有谁知道我如何发送电子邮件附件中的大型 CSV 文件?也许我写的语法不正确?
【问题讨论】:
标签: ruby-on-rails csv gmail mime-types actionmailer