How can I extract an attachment from the email body (encoded as base64)

Solution 1:

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

Solution 2:

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.

Solution 3:

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.