Skip to main content

Opening winmail.dat (TNEF) files in Thunderbird (on Ubuntu)

 
UPDATE: I have an improved version of the script available here.

I'm not going to repeat the many, many websites taking (and complaining) about Microsoft's proprietary e-mail attachment format called TNEF.

I'm assuming that if you are reading this then you have found that these fixes are not working for you (or not possible to enforce). I'll also assume that the LookOut Thunderbird Add-on by Aron Rubin is also not working correctly for you (this was my experience on Ubuntu Edgy Eft).

The best solution I could come up with was getting Thunderbird to run a script to unpack the winmail.dat extension into a folder on your Ubuntu desktop.

It relies on the tnef command-line program, so make sure that is installed first (it's bundled with Ubuntu):
sudo aptitude install tnef
Below is my little script, save it in a file called 'tnef.sh' somewhere and make sure it's executable (chmod +x tnef.sh) - or just download it here.
#!/bin/bash

LOCATION=~/Desktop/winmail.dat

mkdir $LOCATION
/usr/bin/tnef -C $LOCATION --save-body -f $1
Now find an email in Thunderbird with a winmail.dat attachment. Double click it and select to open it with the newly saved tnef.sh file:



Look on your desktop - there should be a 'winmail.dat' directory with the full contents of the attachment.

Double-clicking on any future winmail.dat file will result in the contents of the attachment to also be added to that directory.

Technorati Tags: , , , ,

Comments

ARBaboon said…
Please note that the version of LookOut on AMO is stale. The reviewers are taking quite some time to review version 1.1 while I have already released 1.2. Version 1.2 seems to fix all the bugs people were seeing both with install and behavior. You can a copy at the project's web site - http://lookout.mozdev.org
Andrew Beacock said…
Thanks Aron, and please note I wasn't trying to put your excellent addon down just showing a different way after I couldn't get it working correctly on Ubuntu.

Please keep up the excellent work on LookOut.
ARBaboon said…
I took no exception to your comment. My real problem is with the AMO folks who have been sitting on the bug fix releases since July 7th. The reason BTW, it was not working on some Linux installs and OS X because I set the temporary file perms to 644 as if I was using chmod instead of 0644 which is the proper octal representation. There were a few other bugs too that I got much help in finding (the more eyes...). Also it is worth mentioning that TNEF carries metadata, not just attachments. External programs cannot feed this metadata back into the mail/calendaring program. The real advantages will be realized when I integrate with Sunbird/Lightning.
Andrew Beacock said…
Thanks for the update regarding your latest features, I'm very interested in what you said about Lightning and the TNEF metadata, I've posted today regarding Thunderbird and vCalendar events in Lightning.

Please keep me informed of any new releases of LookOut and I'll give it another try on Ubuntu soon. :)
Anonymous said…
Hey, thanks for posting your solution to this. LookOut isn't working for me either (LookOut 1.2 on Thunderbird 2.0.0.6 on Ubuntu 7.04) -- it installs, but doesn't seem to do anything with the winmail.dat files. So I extended your solution a bit:

#!/bin/bash

#
# open_tnef.sh
#
# Creates a tmp dir, decodes the given TNEF file into that dir,
# and then launches nautilus for viewing.
#
# TODO: instead of letting random dirs accumulate, keep only
# N-most recent dirs, deleting older dirs
#

#
# Make sure given argument is a TNEF file
#
FILE_TEST=`file $1`
if [ "$FILE_TEST" != "$1: Transport Neutral Encapsulation Format" ]; then
echo "Given argument '$1' is not a TNEF file"
exit 1
fi

#
# Set TMPDIR, if not already set
#
if [ "$TMPDIR" = "" ]; then
TMPDIR=/tmp
fi

#
# Create BASE_DIR, if not already created. All TNEF files will be
# decoded into random subdirs of this BASE_DIR.
#
BASE_DIR=$TMPDIR/open_tnef
if [ ! -d $BASE_DIR ]; then
mkdir $BASE_DIR
if [ "$?" != "0" ]; then
echo "Failed to create dir '$BASE_DIR'"
exit 1
fi
fi

#
# Name of given TNEF file will be used to create a random subdir
# to hold its contents
#
TNEF_FILE_NAME=`basename $1`

#
# Create a random subdir for contents of given TNEF file
#
CONTENT_DIR=`mktemp -d $BASE_DIR/$TNEF_FILE_NAME.XXXXXXXXXX`
if [ "$?" != "0" ]; then
echo "Failed to create dir '$BASE_DIR/$TNEF_FILE_NAME.XXXXXXXXXX'"
exit 1
fi

#
# Open the given TNEF file into the content dir
#
tnef --number-backups -C $CONTENT_DIR -f $1
if [ "$?" != "0" ]; then
echo "Failed to decode given TNEF file '$1'"
exit 1
fi

#
# View the content dir
#
nautilus $CONTENT_DIR
if [ "$?" != "0" ]; then
echo "Failed to launch nautilus"
exit 1
fi
Andrew Beacock said…
That looks like a very useful version of the script, I'll try that out this week and post back once I have an opinion! :)
Anonymous said…
This comment isn't for abeacock, but rather, for anyone else who finds this page via googlemagic.

I was convinced that LookOut wasn't working for me on Fedora Core 6. If I "Save As" or "Detach", it would ask me where I wanted the file. After choosing a destination directory, I found no files. I did this over and over again, disabling various other Thunderbird Extensions along the way, to see if I could uncover the source of a conflict...

Alas, nothing worked.

After a bit of searching, however, I found the attachments successfully detached into /tmp, all 17 copies of them (from the 17 times I tried it -- oops!).
Anonymous said…
Status on June 22, 2009 (for anyone who finds this through Google and is wondering if LookOut still poses problems) - on my Ubuntu 9.04 (64 bit) installation using the latest Thunderbird from the standard repo's, LookOut is working perfectly. So no need for any custom scripting.
Andrew Beacock said…
Cheers for updating the thread!
Anonymous said…
minor tweaks to script:

#!/bin/bash

WINMAIL=$1
DATETIME=$(date +%Y%m%d-%H%M)
LOCATION="/tmp/winmail.dat.$DATETIME"

/usr/bin/clamtk $WINMAIL

mkdir "$LOCATION"
cd $LOCATION
/usr/bin/tnef -C "$LOCATION" --save-body -f $WINMAIL

/usr/bin/nautilus "$LOCATION" &
Andrew Beacock said…
Cheers for the tip!
Gopi Aravind said…
Worked for me!! I use Evolution..Thanks!
Dave said…
I also had the issue where lookout did nothing to my winmail.dat extensions. I'm using thunderbird 3.0.4 with lookout 1.2.10. Solved it as follow: On my linux distro, I do not have sudo rights, so whenever I want to update TB, I run it as root, and hit "check for updates". After upgrading, TB did it's normal "check extension compatibility" and installed a new version of lookout (owned by user root), So when I ran TB as myself again, I did not have any permission on the extension directory. Also could not properly uninstall it as a result (extension disappears from the list, but ~/.thunderbird/.default/extensions/lookout\@aron.rubin/ still exists, owned by user root).
rm -rf'ed that dir, and reinstalled lookout.xpi as user me, et voila!
Mark said…
Thanks for this app works very well. once i deleted my conflicting file which was also called winmail.dat it worked.
Mark said…
Thanks for this app once i deleted a file that i already had called winmail.dat it worked ,
cheers mark