17 Dec 2004 (updated 17 Dec 2004 at 08:02 UTC)
»
Fun with 'winmail.dat' attachments
Ever had one of these? Likely you have if someone sent you a calendar, contact entry, or attachment from Outlook without thinking too hard about what they were doing.
The story behind them is rather long and boring: the short version is that they are something called TNEFs (transport neutral encapsulation format) which (in the case of calendar entries, contacts, and tasks) are extended to contain MAPI (messaging application programming interface) properties. If memory serves me correctly, Microsoft was originally hoping to get TNEFs adopted as the standard for encoding any form of electronic communication. Fortunately, that effort failed.
Unfortunately, TNEF lives on as a way of encoding "leftover" information in an outgoing e-mail that does not fit neatly into a MIME message (why this sometimes includes file attachments escapes me at the moment).
Today being the Evolution hackfest and all, I thought it might be a neat idea to put my company's decoder for this format (called WvMapi, originally designed for our Evolution connector) to more general use by writing an E-Plugin for decoding contact and calendar attachments in Outlook-created messages.
It sounded like a great idea on the surface. Peter Colijn, Michel Émond, and myself had spent tons of energy making sure that WvMapi decoded just about everything you threw at it properly (the MAPI recurrence format for appointments is not pretty, let me tell you). Moreover, WvMapi spits out icals and vcards, which (according to the evo hackers) would be trivial to format into something that could be displayed in Evolution's mailer.
Alas, WvMapi is currently limited to parsing TNEFs which are exported directly from Outlook's data stores (and thus contain their full names, dates, descriptions, etc. inside a TNEF attribute called attMapiProps) and it seems as if the ubiquitous 'winmail.dat' attachments encode all of their MAPI goodness inside of the attAttachment attribute. I don't think it would be all that much effort to extend WvMapi to handle this sort of case (Lukasz Kosewski decoded how attachments are encoded in TNEFs during his last work term at NITI: I should see about getting his documentation and example code released as open source), but it's probably not a one day project.
For those looking for a more immediate route to getting this sort of thing going, I'd recommend looking at the ytnef project. Playing around with the converter a bit, I managed to get it spitting out some simple icals and vcards from winmail.dat's. I have a hard time believing that it does as good a job at decoding MAPI properties as we do, but maybe I'm just being arrogant. I didn't look at it much further because of potential licensing/IP issues: ytnef is licensed under the GPL, and I may be forced to use WvMapi in my company's closed source projects.