I'm trying to send an email with a csv attachment from a Unix box to a recipient who is using Outlook 2010. The csv has very long lines (approx. 2000 - 3000 characters).
The file is fine on Unix but when the recipient receives the file there are extra exclamation marks(!) and new lines approx every 1000 characters. Here is some example code I've tried:
outputFile="/tmp/testemail"
attachFile="/tmp/test.csv"
(
echo "From: sender@somedomain.com"
echo "To: receipent@someotherdomain.com"
echo "Subject: Test"
echo "Mime-Version: 1.0"
echo 'Content-Type: multipart/mixed; boundary="GvXjxJ+pjyke8COw"'
echo "Content-Disposition: inline"
echo ""
echo "--GvXjxJ+pjyke8COw"
echo "Content-Type: text/plain"
echo "Content-Disposition: inline"
cat $outputFile
echo ""
echo "--GvXjxJ+pjyke8COw"
echo "Content-Type: text/csv"
echo "Content-Disposition: attachement; filename=test.csv"
echo ""
cat $attachFile
) | /usr/lib/sendmail -t
I've also tried going through the different types of content-transfer-encoding listed here: https://en.wikipedia.org/wiki/MIME#Content-Transfer-Encoding. But none seemed to help.
Sendmail breaks long lines (>990 chars) send over SMTP -> you should send the files using quoted-printable encoding. You may use e.g. qprint
program for conversion.
quoted-printable encoding handle "too long" lines. You may also consider specifying charset used (e.g. ISO-8859-1 or UTF-8) or US-ASCII will be assumed as default.
...
echo "Mime-Version: 1.0"
echo "Content-Type: text/csv; charset=utf-8"
echo "Content-Transfer-Encoding: quoted-printable"
echo "Content-Disposition: attachement; filename=test.csv"
echo ""
qprint -e $attachFile
...