MAPIInitialize fails when running as a service and when Outlook is open

0

We have an application that can run as a Windows service (or as a user mode app). As part of it's processing, it launches a second executable that interacts with MAPI to read the contents of an MSG file. The executable is 32 bit. Office is 32 bit. So far, we've only tested using Outlook 2013.

This has worked fine for quite some time, but we've recently discovered a corner case where things do not work.

When we run as a Windows Service, and Outlook is not running in the user's session, then the application runs properly. However, if we launch Outlook, then MAPIInitialize fails with a return code of -7 (0xfffffffd).

I've tried calling with and without the MAPI_NT_SERVICE flag added (honestly, I can't figure out what that flag actually does), but it makes no difference.

So far in our testing, the Windows service account has been the same as the user logged into the Windows session that has Outlook installed - not sure if that might be important or not.

I can't for the life of me figure out how a process running under one session could interfere with a process running in another session.

I found this post a few minutes ago: https://social.msdn.microsoft.com/Forums/office/en-US/7a9cc40a-ffd6-4f83-9973-5410615b4df4/mapi-working-when-accessed-from-normal-application-but-not-from-the-service?forum=outlookdev

I'll give that a shot, but it seems super unlikely that this could be the issue (it's not like we do anything different with COM initialization, and certainly that wouldn't have anything to do with whether Outlook was running or not).

Can anyone point me in direction(s) to pursue this?

=============

More interesting information:

This appears to only happen with Outlook 2013. It definitely does not happen with Outlook 2010.

com
windows-services
mapi
asked on Stack Overflow Sep 23, 2015 by Kevin Day • edited Oct 2, 2015 by Kevin Day

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0