none
OpenMsgStore E_INVALIDARG RRS feed

  • Question

  • I am working on Exchange 2007 on Windows Server 2008 R2.  I am using ExchangeMapiCdo 1.2.1.  I facing an issue with OpenMsgStore().


    HRESULT SSExchangeServerSession::OpenMsgStore(wstring strStoreName, LPMDB* lppMsgStore)
    {
        HRESULT hr = S_OK;
        char pszStoreDN[MAX_PATH];
        SBinary EntryId = {0};
    
        hr = HrOpenExchangePrivateStore(m_lpMapiSession, &m_lpMDB);
    
        if (S_OK != hr)
        {
            SS_MAPIDLL_Log(SS_ERROR, IDS_FAIL_OPEN_EXCHANGE_STORE, hr);
            goto cleanup;
        }
    
        hr = m_lpMDB->QueryInterface(IID_IExchangeManageStore, (void **) &m_lpIManageStore);
    
        if (S_OK != hr)
        {
            SS_MAPIDLL_Log(SS_ERROR, IDS_FAIL_QUERY_INTERFACE, hr);
            goto cleanup;
        }
    
        hr = HrGetServerDN(m_lpMapiSession, &m_pszServerDN); 
    
        if (S_OK != hr)
        {
            SS_MAPIDLL_Log(SS_ERROR, IDS_FAIL_GET_SERVER_DN, hr);
            goto cleanup;
        }
    
        sprintf(pszStoreDN, "%s%s", m_pszServerDN, "/cn=Microsoft Private MDB");
    
        hr = m_lpIManageStore->CreateStoreEntryID((char *)pszStoreDN, 
            (LPSTR)strStoreName.c_str(),
            OPENSTORE_USE_ADMIN_PRIVILEGE |
            OPENSTORE_TAKE_OWNERSHIP,
            &EntryId.cb,  
            (LPENTRYID*)&EntryId.lpb);
    
        if (S_OK != hr)
        {
            SS_MAPIDLL_Log(SS_ERROR, IDS_FAIL_CREATE_STORE_ENTRYID, hr);
            goto cleanup;
        }
    
        hr = m_lpMapiSession->OpenMsgStore(0, 
            EntryId.cb, 
            (LPENTRYID)EntryId.lpb, 
            NULL, 
            MDB_NO_DIALOG |
            MDB_NO_MAIL | 
            MDB_TEMPORARY | 
            MAPI_BEST_ACCESS,
            lppMsgStore);
    
        if (S_OK != hr)
        {
            SS_MAPIDLL_Log(SS_ERROR, IDS_FAIL_OPEN_MSG_STORE, hr);
            goto cleanup;
        }
    
    cleanup:
    
        return hr;
    }
    

    In the code snippet provided above, the following are values of variables 'pszStoreDN' and 'strStoreName', which appear correct.

    pszStoreDN = "/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=SPD/cn=Microsoft Private MDB"
    strStoreName = "/O=FIRST ORGANIZATION/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=ADMINISTRATOR"


    The call to CreateStoreEntryID() is successful, however, the call to OpenMsgStore() fails with E_INVALIDARG.

    Any help would be appreciated.  Thanks in advance.


    Friday, September 28, 2012 1:36 PM

Answers

  • Yes, flags were same.  I have resolved it.  It was an issue with 'lppMsgStore', a silly mistake.  Thanks for your help though.

    Thanks.

    Friday, October 12, 2012 12:52 PM

All replies

  • Have you tried to use the OPENSTORE_HOME_LOGON flag?

    Can you open that store in MFCMAPI or OutlookSpy?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!


    Friday, September 28, 2012 3:09 PM
  • Hi Dmitry,

    Thanks for the response. I tried all combinations of the following flags - OPENSTORE_USE_ADMIN_PRIVILEGE | OPENSTORE_HOME_LOGON | OPENSTORE_TAKE_OWNERSHIP. The error code is always E_INVALIDARG.

    The arguments provided to OpenMsgStore() appear correct to me. In MFCMAPI on my setup "Default Store" and "Open other mailboxes" show a greyed out sub-menus.

    Thanks.

    Saturday, September 29, 2012 2:29 PM
  • Are you using an online Exchange profile?

    What do you see in OutlookSpy (click IMsgStore | IExchangeManageStore)?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Saturday, September 29, 2012 6:03 PM
  • I didn't understand your first question.

    I installed MS Outlook and OutlookSpy on a different machine. I am trying to avoid having Exchange Server and MS Outlook on the same machine.

    On clicking IMsgStore | IExchangeManageStore, I see the following screen.

    Using OutlookSpy and flags OPENSTORE_USE_ADMIN_PRIVILEGE | OPENSTORE_TAKE_OWNERSHIP, I could go to a messages (IMessage) and its attachments (IAttach) of another user.


    Thanks for OutlookSpy, it is a nifty tool; I have used it in the past. 

    Monday, October 1, 2012 11:41 AM
  • When you look at the binary contents of the store entry id displayed by OutlookSpy and the entry id that you are using, do you see any differences?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Monday, October 1, 2012 5:03 PM
  • Yes, I do see a difference.  I am comparing the EntryId variable in the code with IMsgStore - Mailbox - <UserName> property PR_ENTRYID in OutlookSpy.

    Wednesday, October 3, 2012 10:44 AM
  • And what are the differences?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Wednesday, October 3, 2012 2:16 PM
  • The entry-id that doesn't work is the following:

    From debugger.

    EntryId = {cb=66 lpb=0x025f1918 "" }

    {abFlags=0x025f1918 "" ab=0x025f191c "8¡»å¡»" }

    The entry-id that works from OutlookSpy (IMsgStore PR_ENTRYID):

    cb:168, lpb: 00 00 00 00 38 A1 BB 10 05 E5 10 1A A1 BB 08 00 2B 2A 56 C2 00 00 45 4D 53 4D 44 42 2E 44 4C 4C 00 00 00 00 00 00 00 00 1B 55 FA 20 AA 66 11 CD 9B C8 00 AA 00 2F C4 5A 09 00 00 00 53 50 44 00 2F 4F 3D 46 49 52 53 54 20 4F 52 47 41 4E 49 5A 41 54 49 4F 4E 2F 4F 55 3D 45 58 43 48 41 4E 47

    Thursday, October 4, 2012 8:06 AM
  • What is the whole entry id that you are seeing in the hex format?

    Are you sure you pass the rigth data when creating the entry id? 66 bytes (compared to 168) is way too low.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Friday, October 5, 2012 4:45 PM
  • I tried to run my application from the machine where OutlookSpy works, I am facing the same issue.  Looks like something wrong with my code, however, all APIs are returning success.  I will keep investigating this.  Thanks for your help with this issue.

    Monday, October 8, 2012 1:21 PM
  • I resolved the entry-id issue.  The problem was strStoreName in CreateStoreEntryID() was wstring, I converted it to a string class before using it.  Now both entry-ids are same, however, still the error code for OpenMsgStore() remains the same E_INVALIDARG.
    Tuesday, October 9, 2012 2:15 PM
  • Do you pass exactly the same flags?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Thursday, October 11, 2012 9:05 PM
  • Yes, flags were same.  I have resolved it.  It was an issue with 'lppMsgStore', a silly mistake.  Thanks for your help though.

    Thanks.

    Friday, October 12, 2012 12:52 PM