Processing Outlook .MSG messages

Rebex MailMessage class was originally designed to work with e-mail messages in MIME format - this format is used by almost all Internet email transmitted via SMTP.

However, MIME is far from being the only e-mail message format in existence. Microsoft's legacy winmail.dat format (actually called TNEF) has been frustrating recipients all over the world for more than two decades, as documented by old Usenet posts (such as this, this, or this).

There is also another format - let's call it .MSG - which is used by Microsoft Outlook. This popular e-mail client still can't even save a message into a MIME (.eml) format, although it's now at least able to load it (which is a surprisingly recent feature).

Fortunately, with Rebex Secure Mail, you don't usually have to care about these alternative formats because our MailMessage object has supported them for years. But this ease-of-use comes at a cost: Internally, MailMessage is still entirely MIME-based, which means that loading a .MSG file actually involves its conversion into the MIME format (saving a reverse process). MIME doesn't support all .MSG properties, which means some of them get lost in the process.

In many scenarios, this is not an issue. However, when the goal is simply to modify an existing .MSG file (by adding or removing an attachment or a recipient, for example), this is undesirable.

After considering various solutions (such as refactoring MailMessage to use a non-MIME internal representation able to hold both MIME and MSG data, or holding both MIME and MSG side-by-side), we settled on a simple one: Provide a new OutlookMessage object that resembles MailMessage, but uses Outlook's native format internally. It doesn't (yet) make all of those fancy MSG properties accessible, but it does persist them.

// create an instance of OutlookMessage class
var message = new OutlookMessage();

// load an Outlook .MSG mail message
message.Load("Outlook-mail.msg");

// work with the message
// ...

// save the message
message.Save("Outlook-mail.msg");  

This might become a part of Rebex Secure Mail in the future (it's not yet polished enough for that). But it's too useful to keep to ourselves - we have published it at Rebex Labs and you can give it a try. And if you find it useful or miss a feauture, let us know.