I have worked a bit with an email attachment issue, and can now send attachments through email, through a script.

When the email comes in, I double-click the attachment, and Excel 2016 opens, with a dialog reading: We found a problem with some content in 'attachment.xlsx'. Do you want use to try to recover as much as we can? If you trust the source of this workbook, click Yes. I click Yes, it works. If I open the original file from the same server through Samba, it works fine. Only after it's gone through email does it appear to not be perfect.

What can I do to get rid of this dialog, so the recipient does not see it constantly? I plan on running the script weekly, with a new Excel file each week.

The command that runs: (uuencode /path/to/file.xlsx file.xlsx; echo $BODY) | mail -r me@example.com -s "Subject Line" user@example.com

The file size is increased by 1 byte after being emailed. In this case, it's now 18738 bytes after being emailed. The SHA256 hashes are different between the two files.


uuencode definitely changes the file. You would need to uudecode on the other end to get the original file back.

To prove this to yourself run this:

uuencode /path/to/file.xlsx file.xlsx > testfile.xlsx

Do you get a valid Excel file?


uudecode /path/to/testfile.xlsx testfile.xlsx > testfile2.xlsx

Is testfile2.xlsx a valid Excel file?

SOLUTION: You can either decode the file on the other end or use a modern mail attachment function: You can add the heirloom-mailx package to Debian to add the -a attachment feature.

  • To use this method you would need to decode the file on the other end. This is not the way you should be sending attachments. This was how they sent attachments in the 1970's before MIME types. – HackSlash Jun 14 at 21:04
  • Nevermind, this works if I manually specify "heirloom-mailx -a ..." – Canadian Luke Jun 14 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.