I have an email stored in plaintext (yes, headers, messages, attachments, everything in one plaintext file) and I'd like to extract a PDF document from it. I've copied the base64-encoded text, then ran it through base64 -d and catted it to a file. I then tried opening it up, which didn't work, and it doesn't appear like a PDF file.Is there something I'm doing wrong here? I'm fairly certain that it is, indeed, encoded in base64 and that it's a PDF file. Here is the email:---------- MESSAGE FOLLOWS ----------Date: Tue, 6 Mar 2012 12:24:24 -0800 (PST)From: Outer, Inc. <admin@outer.com>To: Mike Young <inner@outer.org>Message-ID: <169371530.01331065464959.JavaMail.admin@outer.com>Subject: Your results are in, Mike!MIME-Version: 1.0Content-Type: multipart/mixed;     boundary=----=_Part_0_1998493940.1331065464916X-Peer: 127.0.0.1------=_Part_0_1998493940.1331065464916Content-Type: multipart/alternative;     boundary=----=_Part_1_1254200493.1331065464936------=_Part_1_1254200493.1331065464936Content-Type: text/plain; charset=us-asciiContent-Transfer-Encoding: 7bitGreat job, Mike on your baby!------=_Part_1_1254200493.1331065464936Content-Type: text/html; charset=us-asciiContent-Transfer-Encoding: 7bit<html>    <body>        <h3>Great job, Mike on your baby!</h3>    </body></html>------=_Part_1_1254200493.1331065464936--------=_Part_0_1998493940.1331065464916Content-Type: application/pdf; name=Baby Results.pdfContent-Transfer-Encoding: base64Content-Disposition: attachment; filename=Baby Results.pdfJVBERi0xLjQKJeLjz9MKMyAwIG9iaiA8PC9UeXBlL1hPYmplY3QvQ29sb3JTcGFjZS9EZXZpY2VHcmF5L1N1YnR5cGUvSW1hZ2UvQml0c1BlckNvbXBvbmVudCA4L1dpZHRoIDI1My9MZW5ndGggMTYx...HR5P9F0eg4+P8tWzo2bPl6eGcNwyLqqW+chQi7Fo/CTWPUI7Kud1ZYgpcnSg7do4SKpTy10jyggP1dVbvqS63pYxNl1JGGcvD1P+VFdN2b7O3YBqXTuiRteun3nmUdcoObmr5qduv09
Extracting a file attachment from an email message and saving it to a file?
email;pdf;base64
munpack seems like the tool you want. 