I am using MAPI for tracking the incoming messages. (using C++) I have called MAPIInitialize and LAPILogonEx as follows:

    HRESULT hr;
    hr = MAPIInitialize(0);
    IMAPISession *pSession;
    hr = MAPILogonEx(0, NULL, NULL, 0, (LPMAPISESSION *)&pSession);

I want to register this for notifications as I want to track the incoming messages. So I tried to call the IMAPISession::OpenMsgStore before calling IMsgStore::Advise as follows:

   IMsgStore *imsg = NULL;
   hr = pSession->OpenMsgStore(NULL, NULL, 0, NULL, 0, &imsg);

But the above call does not work (It returns -2147221241). I am passing 0 to the Entry ID because I want to track messages in all the folders. Can someone please help me about where I am going wrong? Any help would be much appreciated. Thanks

有帮助吗?

解决方案

The error is MAPI_E_INVALID_ENTRYID. You cannot pass NULL for the entry id. You need to call IMAPIsession::GetMsgStoresTables, find the message store that you need, then pass its entry id to OpenMsgStore.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top