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
Written by Valentino
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#