开发者

MAPI_E_NOT_FOUND on OpenMsgStore

I'm trying to open the MessageStore of a user using MAPI. The weird thing is, when I run this a console application, while I'm logged with the user, everything works fine.

But when I run this as a Windows Service I get MAPI_E_NOT_FOUND when trying to open the MessageStore.

I already configured the service to run as the user.

MapiLogonEx seems to work fine and GetMsgStoreTables also gives me the correct results (I verfied that the EntryID of the MessageStore is correct).

Here's my code:

LPMAPITABLE     pStoresTbl = NULL;
m_lpMAPISession->GetMsgStoresTable(0, &pStoresTbl);

// Query Collumns
LPSPropTagArray pTags = NULL;
LPSRowSet pRows = NULL;
pStoresTbl->SeekRow(BOOKMARK_BEGINNING,0,NULL);
pStoresTbl->QueryRows(
                LONG_MAX,
                NULL,
                &pRows);


LPSBinary lpEntryID = NULL; 
ULONG iprops;
for (iprops = 0; iprops < pRows->aRow[0].cValues; iprops+开发者_C百科+)
{               
    SPropValue sProp = pRows->aRow[0].lpProps[iprops];
    if (PROP_ID(sProp.ulPropTag) == PROP_ID(PR_ENTRYID))
    {
        lpEntryID = &sProp.Value.bin;
        break;
    }
}


lpMDB = NULL;
HRESULT hres = m_lpMAPISession->OpenMsgStore(NULL,
    lpEntryID->cb,
    (LPENTRYID) lpEntryID->lpb,
    NULL,
        MDB_NO_DIALOG |
        MDB_NO_MAIL |       // spooler not notified of our presence
        MDB_TEMPORARY |  // message store not added to MAPI profile
        MAPI_BEST_ACCESS,
    &lpMDB);    


Is that an Exchange profile? Are you sure you are opening the primary mailbox rather than the PF store?

Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool


Do you pass in the MAPI_NT_SERVICE flag in the MAPIINIT_0 structure when calling MAPIInitialize? I've never not passed it in when running in a service, so I'm not exactly sure what happens if you don't. The MSDN docs say it is required.

MAPI_NT_SERVICE

The caller is running as a Windows service. Callers that are not running as a Windows service should not set this flag; callers that are running as a service must set this flag.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜