Decoding Microsoft Outlook Attachments

From Freephile Wiki

Around this time of year, people share a lot of photos. Pictures of friends, family, the kids, their pets, their Christmas trees etc. The problem is that many of these people are chained to a Microsoft email empire, and thus using email software that

   a) writes html-formatted (or Rich Text) messages by default
   b) encodes attachments in a proprietary way

You yourself have probably seen these messages, where the sender claims to have attached some photos, but all you see is something called "Part 1.2" or "Winmail.dat" If you try to open this attachment, you will see that it is encoded as type application/ms-tnef. It is unlikely that your Linux system will know what to do with it. This message is meant to share with you the utilities that exist to help you receive your Microsoft-using counterparts with the humble grace and compassion appropriate for the season.

ms-tnef[edit | edit source]

ms-tnef stands for MicroSoft Transport Neutral Encapsulation Format, which, because it comes from Microsoft, is neither neutral nor formatted the way standard MIME mail messages are encoded. Although I haven't tested this, some Windows versions of free software may decode these messages automatically by calling on some Windows dll. Still, it would be nice to decode them on a free operating system.

tnef[edit | edit source]

Enter the linux utility tnef. tnef is a command-line utility that can unpack those pesky Microsoft attachments, and is actually included in many (most?) modern Linux distributions. If you do not have it, you can download it from the tnef project site on SourceForge.net

ktnef[edit | edit source]

My Debian Sarge includes a GUI version called ktnef that I is bundled with KDE and integrated into KMail. Located at /usr/bin/ktnef on my system, this utility can be launched and allows you to visually open, examine the contents of, and extract the ms-tnef attachments. Since I use Mozilla for email, it doesn't know what to do with these ms-tnef attachements. So, you must first save the attachment in question before using the utility.

Mozilla helper application[edit | edit source]

To avoid this two-step process of saving the attachment and launching the utility independently, you will want to register the ktnef application as a helper for Mozilla[1]. Open Mozilla and under the 'Edit->preferences->Navigator->helper applications' menu, you will want to associate "application/ms-tnef" with the command "/usr/bin/ktnef". (To find the correct location of the program on your system, issue this command at the command shell: 'locate ktnef') Once you have made this association, you can restart Mozilla and it will be ready to launch ktnef automatically whenever you open such an attachment.

web tnef[edit | edit source]

Don't want to bother with any setup? There is a nice free service at this website that will decode your attachments for you. It is a PHP script that hooks into tnef on the backend. Want to share the goodness of tnef with other people? The neat little PHP script is released under the GPL. You can download the source from that website and setup your own.

tnefclean[edit | edit source]

System Administrator? Maybe you would like it if you never saw another ms-tnef or winmail.dat attachment ever again. Check out tnefclean, a perl script that filters out the ugliness, and by the time you see your email, it looks the way [insert deity] intended it to.

No MIME[edit | edit source]

If the sender is both competent, and open to suggestion, you may be able to suggest to them that they send text-formatted emails, and at least that way any attachment should come across with the correct MIME encoding, rather than encapsulated in ms-tnef.


[1] The Mozilla project just released version 1.0 of Thunderbird, which automatically imports your Mozilla mail settings and messages, so you may want to check that out too. I assume that it is a similar process to hook up ktnef with Thunderbird.

--freephile 23:59, 7 Dec 2004 (EST)