32-bit MAPI app with 64-bit Outlook

19.9k views Asked by At

The 32-bit version of our app is unable to send email using MAPISendMail with 64-bit Outlook installed. It returns an error 0x80004005, about which I can find little information beyond the fact that it seems to be a MAPI initialization error.

According to this MSDN document, MAPISendMail is the one exception to the rule that 32-bit apps can't use 64-bit MAPI. And yet it doesn't work (at least with XP and Vista--we haven't tested Win7/8 yet).

Can anyone shed any light on this?

TIA

3

There are 3 answers

1
Dmitry Streblechenko On BEST ANSWER

There are no exceptions: a 32 bit process cannot load a 64 bit dll. When you have the 64 bit version of Outlook, the 64 bit version of mapi32.dll contains the actual implementation. The 32 bit version of mapi32.dll is a stub that does nothing but return an error.

1
Clemens On

That's not completely true @DmitryStreblechenko, - at least not for the MAPISendMail function. For that, and only for that, it is possible to build a "Outlook64 Bridge". This will then redirect 32bit MAPISendMail calls to 64bit Outlook. That bridge may look like:

[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\Outlook64Bridge]
@="Outlook64Bridge"
"DLLPathEx"="c:\\Windows\\winsxs\\x86_microsof t-windows-mapi_31bf3856ad364e35_6.1.7600.16385_none_ab239772 7b134496\\MAPI32.DLL"
"DLLPath"="c:\\Windows\\winsxs\\x86_microsoft-windows-mapi_31bf3856ad364e35_6.1.7600.16385_none_ab239772 7b134496\\MAPI32.DLL"

IMPORTANT, - you have first check to correct path of your 32bit mapi32.dll!

After adding these lines to the reg you have to set the Outlook64Bridge as your default mail client by:

[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail]
@="Outlook64Bridge" 

It is confirmed to work for simple 32bit applications which use really only the MAPISendMail function.

More information can be found here

1
Paolo Branzaglia On

Years ago I'had the same problem. I tried and tried again, but no way ... Microsoft blocked some interactions between 32 bit and 64 bit application: you can't even use 64 bit OCX/OLE in a 32 bit application.

The Outlook Bridge solution above (@VMAtm), worked in the beginning, then Microsoft fixed it, and it stoppend working.

In the end I realized a 64 bit application, my bridge application, to connect main 32 bit application with 64 bit outlook:

  1. Main 32 bit application is running ...
  2. Main 32 bit call bridge 64 bit application; mail data (from, to, title, body ...) are stored in a xml-file. The xml file is passed via command-line.
  3. 64 bridge applicatio starts, and call MAPI functions.
  4. 64 bit outlook does the rest.

This solutions works fine, and I'm quite sure I don't have to struggle with MAPI libraries.