Monday, August 25, 2008

The case of the failed IMAPISession::OpenMsgStore

If you have ever worked with Extended MAPI, you definitely have made call to IMAPISession::OpenMsgStore.

This is one function which has given me sleepless nights, as it just fails for no reason. Some of the situations I found in which it fails are mentioned below

  1. If you use the Account Management API's and then make a call OpenMsgStore for a exchange store, and if you cancel the password prompt the first time, you won't be getting password prompt again, no matter what you do and how many times you call OpenMsgStore. Even logging off from MAPI Session, un-initializing MAPI Session and again logging back doesn't help. For all subsequent calls, it just returns the error 0x8004011D (MAPI_E_FAILONEPROVIDER).

    The only solution to this issue is to re-start your application.


  2. If you call OpenMsgStore for a password protected PST for which the password is not saved, you are prompted to enter the password. If you cancel the password prompt, you get an error 0x80040113 (MAPI_E_USER_CANCEL). For subsequent call to OpenMsgStore you don't get the password prompt. It simply returns the same error.

    The only workaround to this problem is to log off from the MAPI session and log back in.


  3. The last one, if you have a outlook profile in which you have an exchange account, also a PST file and an POP/IMAP account with the PST as your default store for receiving the mails and the POP/IMAP account as the default for sending mails.

    Now in this case, if outlook is closed and you call OpenMsgStore with the MDB_ONLINE flag as mentioned here, it fails with the error 0x8004011D (MAPI_E_FAILONEPROVIDER).

    Currently there is no workaround for this issue.

I have opened support case for all the above issue with Microsoft, for which I am sure are Bugs.

No comments: