0
From the Engine Room

The art of MIME: decoding email images

By 16th May 2011 No Comments

http://www.etresoft.com/decoder.html

It’s an unusual problem but a frustrating one. A client had sent us some emails from an Outlook system which had images attached to them we needed. Straightforward? Not this time! The emails came as attachments, with no filetype, and could only be opened as text documents. Needless to say we don’t have Microsoft Outlook running so we couldn’t open them that way. The text documents were huge, and looked something like this:


Content-Type: image/jpeg; name="Six-spot Burnet moth.JPG"
Content-Description: Six-spot Burnet moth.JPG
Content-Disposition: attachment; filename="Six-spot Burnet moth.JPG";
size=416910; creation-date="Sun, 25 Jul 2004 11:33:28 GMT";
modification-date="Sun, 25 Jul 2004 11:33:28 GMT"
Content-Transfer-Encoding: base64

/9j/4R/+RXhpZgAASUkqAAgAAAAJAA8BAgAGAAAAegAAABABAgAUAAAAgAAAABIBAwABAAAAAQAA
ABoBBQABAAAAoAAAABsBBQABAAAAqAAAACgBAwABAAAAAgAAADIBAgAUAAAAsAAAABMCAwABAAAA
AQAAAGmHBAABAAAAxAAAAGoHAABDYW5vbgBDYW5vbiBQb3dlclNob3QgQTgwAAAAAAAAAAAAAAAA
ALQAAAABAAAAtAAAAAEAAAAyMDA0OjA3OjI1IDEwOjMzOjMwAB8AmoIFAAEAAACGAwAAnYIFAAEA

..and so on for another 600Kb. How could we get this image out of the email? A solution was at hand. Read on to see what it was.

MIME-encoded images are just text

What we have here is a MIME-encoded email. Attachments to emails are encoded as text, and then most email clients translate the attachment back to whatever it started off as – in this case, a JPG photograph of a moth. Usually we don’t see this, as the email program does it automatically. But sometimes it doesn’t work if you take the email out of context – as in our emails here, where it could only be decoded by Outlook, which we don’t use. There are various ways to encode emails, and this one uses a very common system called base64. It might be possible to actually cut and paste the encoded text into a base64 decoding program, and we spent a while trying to do that before realising it wasn’t going to be easy. But luckily in this case we found a better way.

Extracting encoded images from the emails
We found a really great little shareware program that managed to decode the whole email very elegantly. Let us commend to you Etresoft’s Decoder. A simpler program would be hard to imagine. Just drag and drop the problem file onto the program window, and it automatically creates a folder with the extracted information in it. After hours of fiddling, once this little tool was installed the whole job was done in ten minutes, and all the photos decoded. It would work just as well with any other attachment, too.

Etresoft rightly say:

Decoder is particular strong at decoding MIME files from e-mail. Decoder can convert a MIME file into an HTML version of the message, complete with links, inline images, and font styles. In addition, Decoder can recover data from e-mail messages that have been corrupted by an e-mail server or client. Decoder fully supports Macintosh meta-information such as icons, resource forks, comments, etc.

This is a clever little program, well worth using. It’s shareware, so it works fully but asks for a donation of $20. Money well spent when it saves you hours of fiddling with the wonders of MIME.

UPDATE: It looks as though the Decoder software is no longer available from Etresoft. Which is a shame. You can still find it on other websites if you look around.

Leave a Reply