tnef2mime: automatically extract parts from winmail.dat

In her professional life, my fiancée routinely gets emails with attachments in the 'winmail.dat' aka application/ms-tnef format. It does her no good to berate these prisoners of proprietary software, so I set out to provide her with an easy-to-use solution that would work on her end. Now, prompted by this blog entry I am posting it for others to use.

There are a number of programs that can rescue data from this proprietary attachment format, but I was not aware of a program that would automatically convert the winmail.dat attachment to (a series of) regular mime attachments. (it appears that ytnef_smtpd may be such a program)

So I wrote one, tnef2mime.py. tnef2mime reads a message on standard input, combs it for ms-tnef attachments, and uses the tnef(1) program to extract their contents. Then it takes the extracted files, adds them as new MIME parts, and prints the whole resulting message.

This is suitable for use in e.g. procmail:

:0fw
| tnef2mime

Several steps are taken in order to minimize the chances for data loss: Just in case it did an imperfect job, it leaves the existing ms-tnef attachment intact. If any problem is encountered, the unmodified message is written.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Files currently attached to this page:

tnef2mime.py3.1kB



Entry first conceived on 20 September 2011, 18:49 UTC, last modified on 15 January 2012, 3:46 UTC
Website Copyright © 2004-2017 Jeff Epler