Last Updated: February 25, 2016
· codenamev

Sending CSV attachments with lines longer than 990

If you are ever trying to send a CSV attachment with a plain text mime type of text/csv, it will wrap the content every 990 characters (ref: RFC 2045/821).

To fix this, Base64 encode the attachment:

attachments['file.csv'] = {
  :data => ActiveSupport::Base64.encode64(@csv_string),
  :encoding => 'base64'

Thanks you StackOverflow for pointing this out