Open Winmail.Dat

Microsoft Outlook emails are stored in a special archive file format (MIME type ms-tnef) called winmail.dat. What follows is a basic Shell Script to open / extract the contents of a Microsoft Outlook winmail.dat file.

TNEF is a Linux Command Line program / tool that open /extracts content from ms-tnef formatted (like winmail.dat) files.

Install TNEF via the Ubuntu Software Center or from Terminal Session with:

sudo apt-get install tnef

The TNEF Man Page can be found at: http://linux.die.net/man/1/tnef

A typical usage of TNEF is:

tnef --file=/foldername/winmailfilename --directory=outputfoldername

Here is a Shell Script to ease the process:

#!/bin/bash

# Open Microsoft Outlook Emails (MIME type ms-tnef)
# Options -
# -t - list attached files, do not extract
# --file= - specify complete path and file name to process
# --directory= = specifies loaction where winmail contents are deposited

read -p "Key-in complete winmail path and filename: " winmailfilename
read -p "Key-in directory to contain winmail content: " outputdirname
read -p "List winmail contents? (y/n) " answer
if [ "$answer" == "y" ]
  then
    echo "Listing winmail contents..."
    optListOnly="-t"
elif [ "$answer" == "n" ]
  then
    echo "Opening winmail file..."
    optListOnly=" "
else
  echo "Bad reply, try again."
  exit
fi

tnef --file=$winmailfilename --directory=$outputdirname $optListOnly