Avoiding and converting winmail.dat Files

Avoiding and converting winmail.dat Files

Avoiding winmail.dat files in Domino

 

It’s happened to most Notes users at one time or another: someone who uses Outlook sends you an e-mail, and instead of getting a nicely formatted message with an attachment, you end up with some plain text and a big file at the end called either “Winmail.dat” or “ATT0001.dat”

This is because whoever sent you the message has their mail client set up to send messages in Microsoft Rich Text format that in turn will bundle the message and all its attachments into a file that’s encoded in Transport Neutral Encapsulation Format (TNEF).

Unfortunately, while the TNEF format might be “transport neutral”, it’s far from being “application neutral”, and many non-Outlook clients don’t really know how to interpret the message. The result is a plain text message that has a .dat file attached to it.

Fortunately there are a number of back-end server ways of preventing this from happening, and as a last option a Lotus Notes Agent can be deployed to users’ Mailfiles to convert the winmail.dat to a readable format.

Office 365

You must set the Remote Doamin to TNEFEnabled $False

e.g.

set-RemoteDomain “domino.contoso.com” -TNEFEnabled $False

PS C:\Users\conra> Get-RemoteDomain “domino.contoso.com” | FL TNEFEnabled

TNEFEnabled : False

Microsoft Exchange

Configure the Remote domain Settings

In Exchange ensure that you have the Remote Domain set to Never use Exchange Rich-Text format

TNEFEnabled

 

Recipient Preferences in the GAL

If you have the recipients listed as Contacts or Mail-Enabled Users you can configure them directly

Set the Use MAPI rich text format to NEVER.  You coul use a PowerShell script to se this attrribute for ALL of your Domino Users in the Exchange GAL that have not yet been migrated.  Those users might be represented as AD Contacts or Mail-Enabled Users.  This is espeically useful for Mail-In Databases as well as Rooms & Resources.

02. Recipient Preferences

or:

C:\Users\conra> Set-MailUser notes.user@contoso.com -UseMapiRichTextFormat Never
C:\Users\conra> Set-MailUser notes.user@contoso.com -UsePreferMessageFormat $True

 

On Domino Server

The following notes.ini settings can be utilised on Domino

 

TNEF Notes:

Beginning with IBM Domino 9.0.1FP4 TNEFEnableConversion now enabled by default. Setting the ini TNEFEnableConversion=1 is no longer necessary. However, should you not want this feature enabled. You would need to set this parameter TNEFEnableConversion=0 in your servers Notes.ini file.

Converting TNEF file attachments to Notes file attachments

Transport Neutral Encapsulation Format (TNEF) is a Microsoft standard for tunneling rich data over the Internet to a recipient. Rich data includes Microsoft Rich Text Format (RTF) text, OLE objects, file attachments, and other application data such as Microsoft Outlook calendar data. Microsoft Outlook clients and Microsoft Exchange can be configured to format emails for sending to recipients who use Microsoft Outlook. In such a configuration, Microsoft Outlook sends the RTF data as plain text and places all other objects into the TNEF stream, which is usually attached to the email as a file named winmail.dat.

IBM® Lotus® Domino® uses the TNEF Converter feature to extract file attachments from the TNEF stream and attach them to an IBM® Lotus® Notes® document as Notes file attachments. The TNEF Converter runs on a Domino SMTP server. To enable the TNEF Converter feature, add the following NOTES.INI file setting to the NOTES.INI file on the server:

TNEFEnableConversion=1

The TNEF Converter can process TNEF objects in an S/MIME signed message, but doing so invalidates the signature. By default, the TNEF Converter does not process S/MIME signed messages at the server. You can use the NOTES.INI file setting below to force the TNEF Converter to process S/MIME signed messages at the server.

TNEFBreakSMIME=1

The TNEF Converter can not process objects in an S/MIME encrypted message because it can not decrypt the message on the server.

The TNEF converter can only handle clear signed messages. S/MIME clear signed messages are sent as a multiple part signed message. The first part of the multiple part signed message is the original message, which may in turn be multiple part. The second part of the multiple part signed message is the signature. Unlike an opaque signed message, the clear signed message’s data is in the clear. The TNEF Converter can find and open the TNEF stream, extracting any attachments contained within the TNEF stream.

 

At the Client Level

Outlook Mail Format

 

On the Outlook Client you can change the Mail Format itself within the Message.  Choose HTML or (Plain Text to guarantee 100% readability by the Mail Recipient – but that’s no fun 🙂 )

Outlook Mail Format

Recipient Preferences

On Outlook you can set Recipient preferred preferences. Find the user in your Personal Contacts and open the email properties.

04. Outlook Recipient Preferences1

 

04. Outlook Recipient Preferences

Converting winmail.dat files in Lotus Notes

In the Java TNEF library by Amichai Rothman. Somehow, Mr. Rothman discovered the secrets of the TNEF format and wrote an entire Java library to decode those pesky .dat files. Since he made his code/library available as open-source, and since Lotus Notes 6.x has all the required components already built-in, I was able to write an agent that handles all the message extraction for you.

The agent is available for download at: Converting Winmail.dat Files In Your Mail. The agent is meant to be placed in your Notes mail file and set to run against selected documents, so you can just select the messages that you want to convert and run the agent against them. If the conversion was successful, a new copy of the message will be placed in your Inbox folder, with the extracted files attached at the bottom.

I have attached a shell DB here, all you need to do is copy and paste the Agent in to your (or a users) mail file. You could either create an extra Action Button on the Action Bar in the inbox folder, or simply advise the user to run it from the Action items on the Menu Bar.

The agent can be run from within the mail, or from the Inbox folder. Anyone can run the agent, not just the mail file owner.

I have also made this code available in a mail-in database, which is often a lot easier to implement in a corporate setting. You just copy the database to your server, set it up as a mail-in database, and when users forward their e-mails with Winmail.dat attachments to it the files inside are extracted and mailed back to the sender. The database is available as a project on the OpenNTF site, at:

=> The WinmailExtractor Database <=

Please note that this agent makes use of the open-source and GPLed JTNEF library by Amichai Rothman. Please visit his site if you have any questions about the underlying TNEF conversion code, or the licensing of his library.

Also, this code was tested using the 1.2.2 version of the jTNEF library. If you have issues compiling the agent, you might want to try using that version, as it seems that version 1.2.3 might be making at least one call to a method that’s not available until Java 1.4 (which is Notes 7 to me and you). The older version is available at:

http://www.freeutils.net/source/jtnef/jtnef-1_2_2.zip