none
MAPIInitialize fails without returning an error RRS feed

  • Question

  • I am using the MAPI to send email in my application which runs as a service. The first step is to call the MAPIInitialize which will fail without returning any error code and the service will stop. 

    When I run it under Visual Studio in debugging mode, everything works. 

    Anybody has encountered this problem before? I am using Outlook 2016 32 bit under Window 10.

    Thanks.

    Tuesday, May 16, 2017 5:39 PM

All replies

  • Hello,

    What value does the MAPIInitialize function return?

    Anyway, you may find the MAPI working when accessed from normal application but not from the Service forum thread helpful.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Tuesday, May 16, 2017 5:55 PM
  • Hi Eugene,

    Thanks for the reply. 

    Actually I had read that thread before I posted my question. I think that we are using the same code, but my calling to MAPIInitialize doesn't return anything. When I was using the Visual Studio to attach to the running process, the debug session just stopped in the middle of calling to it.

    Tuesday, May 16, 2017 7:14 PM
  • What version of Outlook are you using?

    How are you loading the MAPI system?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, May 17, 2017 2:01 AM
  • I am using Outlook 2016 (16.0.4266.1003) 32-bit on Windows 10.  

    I am not quite sure that I understand your second question. Do I need to do something special to load the MAPI system? I have the Outlook 2016 client installed on my local.

    The same program with the same configuration works with Outlook 2010 on Windows 7, though.


    Wednesday, May 17, 2017 2:15 PM
  • How do you load the dll that exports the MAPI functions (MAPIInitialize etc.)? You cannot statically link to those functions.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, May 17, 2017 10:36 PM
  • I am using this statement to reference the mapi,

    #pragma comment (lib,"mapi32.lib")

    This is working fine and should not cause any problem.

    Thanks.

    Thursday, May 18, 2017 2:25 PM
  • No, you are statically linking to the mapi32.dll. You should not do that.

    Take a look at the MFCMAPI source code to see how the MAPI system must be loaded.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, May 18, 2017 3:20 PM