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.
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.