Here’s a fun trick. On a machine where you have the Exchange MAPI Download installed, create a file named “Program” in the root of the system drive. Then start MFCMAPI and open a profile with an Exchange mailbox in it. You’ll get this nice error:
Of course, restarting MAPI applications, or even rebooting, won’t help. You have to delete that file, “Program”, from the root of the system drive. Only then will the MAPI spooler start.
So – what happened here? We’re using CreateProcess to try to launch the spooler. The string we pass in for the command line looks like this:
C:\Program Files (x86)\ExchangeMapi\MAPISP32.EXE –0001EFC1A5208C4
Note the distinct lack of quotes. As the documentation suggests, if you call this function with a path which has white space in it and no quotes, it will try to parse the path as if the first space separates the executable name from the parameters. So it looks for an executable named “C:\Program”. When it finds a file with that name which is not an executable, it returns an error. The lesson here is to make sure to properly quote paths passed to CreateProcess. Also, make sure you don’t have a file named “Program” in the root.
Outlook’s MAPI is not vulnerable to this problem since it no longer has a separate MAPI spooler process. I don’t believe we’ll be pursuing a fix to the Exchange MAPI download since the likelihood of such a file existing for legitimate purposes is low, and you need to be an administrator to even create it in the first place.