Help!! MAPILogonEx issue!!!

Oct 15, 2013 at 6:32 AM
Edited Oct 15, 2013 at 7:45 AM
Hello!

Could anybody help me with this problem:

I trying to write NT Service that works with MS Exchange Server. When I
call
MAPILogonEx() it returns with -2147221231 (ClassFactory cannot supply
requested class). the Service is executed under the local system account, but i call MAPILogonEx with administrator account, it success, What is the problem, what am i doing wrong?

here is my code:

HRESULT hRes = ::MAPIInitialize(NULL);

ULONG ulFlags = MAPI_EXTENDED | MAPI_ALLOW_OTHERS | MAPI_NEW_SESSION |MAPI_USE_DEFAULT;

hRes = ::MAPILogonEx(
    0,
    NULL,
    0,
    ulFlags,
    &_lpMAPISession);
Thanks in advance,
Coordinator
Oct 15, 2013 at 1:50 PM
That error is MAPI_E_LOGON_FAILED - it has nothing to do with class factories.

You're not passing a profile name. That means you intend for MAPILogonEx to display UI to select/build a profile. But you're running in a service, which cannot display a UI. So it HAS to fail.

Recommended fix: build the code to build the profile you need, then pass that profile name into MAPILogonEx.