Decode EML Files
Sometimes an E-mail file will not be properly processed by your E-mail client and you are left with a mail that has an attachment .EML file. This file is the complete text of the sent E-mail but if there were attachments these will be encoded and appear in the file as random text.
Some E-mail clients will allow you to import these files and then automatically handle them showing you both the message and allowing you to use the program to handle the attachments. Some may not. It's those that this FAQ addresses.
To work with these files you need to do two things:
- Save the EML file to a location you can find and give the file a .TXT file extension so it will open in a text editor. It's OK if the file has a double extension (e.g., filename.eml.txt) so long as you can open the file in a text editor.
- Obtain a base64 decoding program. There are many Web-based decoders where you can cut/paste encoded text into a dialog box in your browser and the site will then send a decoded binary file back to you. While handy and quick, be aware that when you do this the site doing the conversion could make a copy of the file and do with it as they please. For that reason I prefer to use a standalone decoder. I typically use b64dec. The download is a ZIP file that unzips to a standalone EXE file that can be run from any folder you save it to. No installation necesssary.
Open the EML file in your text editor. The first part of the file should be the mail headers followed by the text version of the E-mail body and then, perhaps, a second section which shows the same E-mail messsage but with HTML tags for a rich-text display. The text of the message should be able to be easily read in the text editor. It's the attachments that you need to decode to see.
Scroll down through the EML file and you should see several boundary markers. They will look something like this...
Content-Type: text/html; charset=ISO-8859-1
...the boundary between the ASCII text version of the E-mail and the HTML version. If the attachment is an image the boundary might look something like this...
Content-Type: image/jpeg; name=080605ML1.jpg
Content-Disposition: attachment; filename=080605ML1.jpg
Note that this boundary header says the following material is a JPEG image named 080605ML1.jpg and that the material is base64 encoded; a standard encoding used for E-mail attachments.
What you want to do is copy all the random-looking text following the boundary down to the next boundary into the dialog box displayed when you start the b64dec program. Once you do that and give a name to the recovered file just click on the Decode button and a file of the name you specified should appear in the program folder (or any other folder you specified when you named the file).
Once you've done that, go back and extract the remaining attachments from the original EML file; one attachment at a time.
Confused? Perhaps a movie would help...