5

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

chrisd
  • 853
  • 1
  • 9
  • 23

3 Answers3

5

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.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • 1
    Right, but the MS documentation explicitly states that 32-bit apps can use `MAPISendMail` because it doesn't load the DLL, it calls fixmapi.exe. HOWEVER, having just looked at it again, I see what I missed the first ten times I read it: "This WOW64 scenario only applies to Windows 7." Thanks for forcing me to read it one more time. :) – chrisd Oct 09 '12 at 19:23
5

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

VMAtm
  • 27,943
  • 17
  • 79
  • 125
Clemens
  • 171
  • 1
  • 3
  • You have redirected to a 64 bit version of mapi32.dll (in x86_microsoft....), as does your reference. Other references suggest using the copy from c:\windows\system32, which is also the 64bit version. This suggests that perhaps you have to first check to CORRECT PATH of your 64bit mapi32.dll! I have no way of checking here: apparently the fix doesn't work with Outlook 2016. – david Feb 22 '18 at 10:18
3

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.

  • I did the same thing and I thought it was working but it is flaky. My 32 bit app with builtin MAPI works great. I built a 64 bridge program as you described with an XML email document. When sending email, I use CreateProcess to spawn the 64 bit app, it reads the XML, and sends the email. Weird thing is, it doesn't always work. Thunderbird (my 64 bit app) pops up on the screen but doesn't send (well, sometimes it does, but not always). So clearly the email app is triggering something in MAPI, as it should, but somethings not right either. If I run the 64 bit MAPI app manually, it works. – KokoCa Sep 08 '20 at 21:21