Sending Mail via MAPI using Outlook Office in 64-bits

23. July 2006 17:05 by Csaborio in General  //  Tags:   //   Comments (0)
We recently received an interesting mail detailing the problems faced when using MAPI to send mail via Office Outlook Express. Here are the symptoms (try and see if you can figure it out by the end of the post):

1. When using MAPI calls in a 32-bit application when Outlook Express is the default e-mail handler, the application creates a blank message (success)
2. When using MAPI calls in a 64-bit application when Outlook Express is the default e-mail handler, the application creates a blank message (success)
3. When using MAPI calls in a 32-bit application when Office Outlook is the default e-mail handler, the application creates a blank message (success)
4. When using MAPI calls in a 64-bit application when Outlook Express is the default e-mail handler, the application does not create a blank message (failure). When the program ran and tried to create an e-mail, the Outlook Express connection wizard showed up.

After comparing registry entries for hours trying to find why Office Outlook was not being recognized as the default e-mail client and why Outlook Express was, it then hit me. There is a 64-bit version of Outlook Express on every 64-bit Windows install, that is why scenarios 1 & 2 above were working! There is some MAPI calls via DLLs, and since there is a 64-bit version of Outlook Express, everything works fine when it is the default e-mail client.

The story with Office Outlook is different. Since it is only 32-bit, when it is registered as the default e-mail client, only the 32-bit section of the registry is affected. That is why when the 64-bit MAPI program tries to send mail, it only sees Outlook Express. This makes sense as the MAPI functionality to work with Office Outlook is a 32-bit DLL, which would not work when called from a 64-bit binary.

As far as what can be done to overcome this problem, you ask? I have not tested this, but if you could build yourself an out-of-process 32-bit COM LocalServer that was responsible for invoking the MAPI functionality of sending mails, you could (in theory) invoke it from a 64-bit application and be done with your bit-dependencies problem.

This link is a great place to start. I will be busy at an event here in Redmond, but if I have some free time I will try to come up with the solution and post it here,