Forum: Ruby on Rails Attach CSV String as attachment

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Mario G. (Guest)
on 2009-04-09 23:30
I am trying to take a csv string output and send it as a file
attachment, but keep my data is only coming out as gobbly gook.  The csv
string is valid going into the mailer action.

Valid CSV

   1000012,Testing project,,Thu Apr 09 16:31:08 UTC 2009,0,0,0.0
   1000013,test,,Thu Apr 09 16:35:19 UTC 2009,0,0,0.0

In Action Mailer, I have:

  def report(csv, name)
    body :name => name
    attachment "text/csv; charset=utf-8" do |a|
      a.body = csv
      a.filename = name

unfortunately, this gives me:

   Content-Type: text/csv; name="New projects"
   Content-Transfer-Encoding: Base64
   Content-Disposition: attachment; filename="New projects"

This topic is locked and can not be replied to.