Results 1 to 2 of 2

Thread: Error while getting pointer of a sub folder

  1. #1
    Nauman Hameed Guest

    Error while getting pointer of a sub folder

    Hi

    I am trying to open the Inbox folder of an Exchange Server mailbox. I
    follow these steps to do this.

    1. Initialize MAPI (MAPIInitialize)
    2. Create a session using an explicit profile (MAPILogonEx)
    3. Get the message stores table (session->GetMsgStoresTable)
    4. Open the required message store after getting the entry ID from the
    table obtained in step 4 (session->OpenMsgStore)
    5. Get the root folder entry ID from the message store (msgStore->GetProps
    to get PR_IPM_SUBTREE_ENTRYID property)
    6. Open the root folder using the entry ID obtained in step 5.
    (msgStore->OpenEntry)
    7. Get the hierarchy table for the root folder
    (rootFolder->GetHierarchyTable)
    8. Get the entry ID of a sub folder, e.g. Inbox, from the hierarchy table (
    the PR_LONGTERM_ENTRYID_FROM_TABLE property )
    9. Open the sub folder using the entry ID obtained in step 8
    (rootFolder->OpenEntry)

    The code works fine upto step 9. The code for step 9 returns successfully (
    hr == S_OK ). However, when I try to use the pointer of sub folder for any
    operations on the sub folder, I get an exception with the message "Object
    reference not set to an instance of an object."

    I have used the GetReceiveFolder method as well (msgStore-
    GetReceiveFolder). The results are same. The entry ID that I get in step 8
    and the entry ID that I get using the GetReceiveFolder are same.
    I have verified the entry ID that I get in my code using OutlookSpy.
    OutlookSpy reports the same entry ID for the Inbox folder. If I use the
    OpenEntry dialog provided by OutlookSpy, it successfully opens the Inbox
    folder using the same entry ID.

    I use following lines of code to open the sub folder (Inbox folder).

    /---------------------------\
    SBinary subFolderEID;
    LPMAPIFOLDER subFolder = NULL;

    ULONG lpulObjType;
    LPUNKNOWN lppUnk = NULL;

    hr = rootFolder->OpenEntry(subFolderEID.cb, (LPENTRYID) subFolderEID.lpb,
    &IID_IMAPIFolder, MAPI_MODIFY, &lpulObjType, &lppUnk);

    subFolder = (LPMAPIFOLDER) &lppUnk;
    \----------------------------/

    In the OpenEntry call I have tried different combinations of flags other
    than MAPI_MODIFY but no use.

    Can anyone provide some insight?

    Thanks
    Nauman

  2. #2
    Nauman Hameed Guest
    Found the solution from another forum. The last line of the code pasted below
    is:

    subFolder = (LPMAPIFOLDER) &lppUnk;

    The & with lppUnk is the culprit. It should be:

    subFolder = (LPMAPIFOLDER) lppUnk; // Without the &

    Nauman

    "Nauman Hameed" wrote:

    Hi

    I am trying to open the Inbox folder of an Exchange Server mailbox. I
    follow these steps to do this.

    1. Initialize MAPI (MAPIInitialize)
    2. Create a session using an explicit profile (MAPILogonEx)
    3. Get the message stores table (session->GetMsgStoresTable)
    4. Open the required message store after getting the entry ID from the
    table obtained in step 4 (session->OpenMsgStore)
    5. Get the root folder entry ID from the message store (msgStore->GetProps
    to get PR_IPM_SUBTREE_ENTRYID property)
    6. Open the root folder using the entry ID obtained in step 5.
    (msgStore->OpenEntry)
    7. Get the hierarchy table for the root folder
    (rootFolder->GetHierarchyTable)
    8. Get the entry ID of a sub folder, e.g. Inbox, from the hierarchy table (
    the PR_LONGTERM_ENTRYID_FROM_TABLE property )
    9. Open the sub folder using the entry ID obtained in step 8
    (rootFolder->OpenEntry)

    The code works fine upto step 9. The code for step 9 returns successfully (
    hr == S_OK ). However, when I try to use the pointer of sub folder for any
    operations on the sub folder, I get an exception with the message "Object
    reference not set to an instance of an object."

    I have used the GetReceiveFolder method as well (msgStore-
    GetReceiveFolder). The results are same. The entry ID that I get in step 8
    and the entry ID that I get using the GetReceiveFolder are same.

    I have verified the entry ID that I get in my code using OutlookSpy.
    OutlookSpy reports the same entry ID for the Inbox folder. If I use the
    OpenEntry dialog provided by OutlookSpy, it successfully opens the Inbox
    folder using the same entry ID.

    I use following lines of code to open the sub folder (Inbox folder).

    /---------------------------\
    SBinary subFolderEID;
    LPMAPIFOLDER subFolder = NULL;

    ULONG lpulObjType;
    LPUNKNOWN lppUnk = NULL;

    hr = rootFolder->OpenEntry(subFolderEID.cb, (LPENTRYID) subFolderEID.lpb,
    &IID_IMAPIFolder, MAPI_MODIFY, &lpulObjType, &lppUnk);

    subFolder = (LPMAPIFOLDER) &lppUnk;
    \----------------------------/

    In the OpenEntry call I have tried different combinations of flags other
    than MAPI_MODIFY but no use.

    Can anyone provide some insight?

    Thanks
    Nauman

Similar Threads

  1. Public Folder ERROR
    By Denis Correard in forum Administration
    Replies: 0
    Last Post: 11-25-2005, 08:47 AM
  2. Error synchronizing folder
    By James Meyer in forum Administration
    Replies: 0
    Last Post: 11-23-2005, 09:58 AM
  3. Public folder error
    By brt in forum Administration
    Replies: 3
    Last Post: 10-06-2005, 09:58 AM
  4. Public Folder Error
    By Chris@NDINC in forum Administration
    Replies: 0
    Last Post: 10-05-2005, 09:58 AM
  5. Error synchronizing folder
    By Bill Freeze in forum Clients
    Replies: 0
    Last Post: 01-26-2005, 04:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other forums: Access Forum - Microsoft Office Forum - CAD Forum