Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I extract attachments from an email when they arrive encoded in the body of the email like this:

------ =_NEXTPART_FORMSCAPE_MAIL_message101122101615
Content-Type: application/octet-stream; name="MyFile_hasalongish
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="MyFile_hasalongishfilename_22-NOV-2010.pdf"
Content-Description: MyFile_hasalongishfilename_22-NOV-2010.pdf

------ =_NEXTPART_FORMSCAPE_MAIL_message101122101615--
share|improve this question
You'll need to find a UUDECODE tool to convert the ASCII to a valid file. – user3463 Nov 22 '10 at 0:37
On what operating system, or with what mail architecture (local unix delivery, fetchmail, Thunderbird, Outlook, ...)? – Gilles Nov 22 '10 at 0:52

3 Answers 3

up vote 1 down vote accepted

Save the email to a text file with the extension .uue and extract the attachment with a de-archiver.

share|improve this answer

I was able to recover the file using a base64 decoder and copying only the actual text that was the encoded attachment, not any of the surrounding header/footer stuff.

share|improve this answer

Copy only the base64 encoded text into a new text file foo.txt.

base64 --decode foo.txt > bar.pdf

I just decoded a base64 stream that had an extra bit on the end that I had to remove. It looked like this: --=_59494bda030d4629113a60ff13935d81--. Before I removed it I got the error: Invalid character in input stream. After I deleted it, no decoding errors and it opened just fine.

share|improve this answer

protected by Nifle Feb 6 at 0:03

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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