|Hacking Outlook Express - COM Interop|
|Written by Mike James|
|Thursday, 23 July 2009|
Page 1 of 5
This article shows how to work with a COM object manually and specifically how to access the Outlook Express message store. It also proves that it is possible to use a primitive COM object from C# or any .NET language as long as you are prepared to do some manual creation of its interface specification.
When Outlook Express was first released an automation library was provided that, in theory, allowed you to work with it from VB 6 or script. However there was no documentation and it didn’t work reliably. With each new version of OE it became clear that Microsoft really didn’t want programmers improving its facilities. As a result only a few programmers took up the challenge and found out how to create OE add-ons.
Microsoft has provided an API that allows access to Outlook Express. The bad news is that it is an old-fashioned COM API, large parts of it are incomplete and it’s very poorly documented. What’s worse is that it doesn’t support an IDispatch interface and this makes it difficult to use from any language other than C++.
In principle you should be able to use any COM object from C# with minimal effort with the help of “COM Interop” but this too only supports COM objects with IDispatch interfaces and needs a type library – which in this case hasn’t been provided. We have no choice but to work with COM objects at the most primitive level.
The Message Store
If you search the web you will find a number of attempts to document the file structure of the OE message store so that it can be read and processed using conventional file I/O. This is a measure of how desperate is the need to access the store.
Decoding a file structure without official help is very difficult and there is no way to be sure that Microsoft won’t change the structure at the next release. A much better route is to use the COM OE API that Microsoft has made available. Even though there are large sections of it marked as “not supported” the IStoreNamespace and the IStoreFolder interfaces are complete and unlikely to change in the future.
IStoreNamespace provides methods that allow you to access and manipulate folders and IStoreFolder gives you access to the messages stored in a folder. Logically we need to start with IStoreNamespace and work with folders.
|Last Updated ( Wednesday, 16 September 2009 )|