UAF Logo ARSC Logo

Decode email attachments
5/4/2012

Decode email attachments

Modern email clients can handle attachments of various types and automatically handle the encoding and decoding of these attachments.

The most common problem with email attachments results from users of Microsoft Exchange and Outlook. When email with attachments from users of Microsoft Exchange and Outlook are received by users not using these products they often see a winmail.dat attachment that the email client cannot decode.

Decode email with Microsoft MS-TNEF MIME attachments

The tnef application can decode most attachments from users of Microsoft Exchange and Outlook.

tnef - decode Microsoft's Transport Neutral Encapsulation Format (TNEF)

The tnef application is open source under GNU General Public License (GPL) and available at: https://github.com/verdammelt/tnef

tnef --body-pref all --number-backups -f winmail.dat

The above extracts all attachment types from the winmail.dat file and uses numbering if more than one attachment exists in the file with the same name.

Base64 Encode/Decode

In some cases the decoded attachment may still have sections in base64 encoding. Split the base 64 encoded sections (not including the description area) into separate text files and decode them with OpenSSL.

Base64 encoding is a standard method for converting 8-bit binary information into a limited subset of ASCII characters for safe transport through e-mail systems, and other systems that are not 8-bit safe. With OpenSSL, it is very easy to encode and decode Base64 data. Note that it may be helpful to name the output file with what is specified in the "name=" line in the attachment.

Encode myfile in base64 encoding:

openssl enc -base64 -in myfile -out myfile.b64

Decode myfile.b64 which is encoded in base 64 encoding:

openssl enc -d -base64 -in myfile.b64 -out myfile.decrypt

This documentation page was retrieved from
https://intrawiki.arsc.edu/index.php/Decode_email_attachments
Friday, May 4, 2012 @ 10:04:55 AM (Alaska Time)
by Lawrence A. Murakami of Fairbanks, Alaska.
ARSC Personal WebPage Disclaimer.