Opening an Existing Private or Personal Folder

You can open an existing folder if you know either its entry identifier or the value of its Display-Name property. It is faster to use the entry identifier if it is known.

    To open an existing private or personal folder
  1. Open the private information store or personal folder store (PST) that contains the folder. This step returns an LPMDB pointer to the open information store. See Opening an Information Store.
  2. Call either the HrMAPIFindFolderEx function or the HrMAPIOpenFolderEx function. In each case, pass both the pointer returned in step 1 and the folder path. See Expressing Paths to Folders. HrMAPIFindFolderEx returns the entry identifier of the folder, which you can use to open it. The HrMAPIOpenFolderEx function locates the folder and opens it.

    – Or –

  3. Open the root folder of the information store by calling the MAPI IMsgStore::OpenEntry method.

    The following sample code shows the call to open the root folder of an information store:

    // Open the parent (or root) folder...
    hr = lpMsgStore->OpenEntry(
        0L,      // use 0L for root folder
        NULL,    // use NULL for root folder
        NULL,    // use NULL for interface ID
        MAPI_MODIFY | MAPI_DEFERRED_ERRORS, // use this flag if you plan to make changes
        &ulObjType,
        (LPUNKNOWN*)&lpParentFolder); 
     
  4. Call the HrMAPIFindSubfolderEx function or the HrMAPIFindSubfolderEx function. In either call, pass both the LPMAPIFOLDER pointer returned in the preceding step and the folder path. See Expressing Paths to Folders. HrMAPIFindFolderEx returns the entry identifier of the folder, which you can use to open it later. The HrMAPIOpenSubfolderEx function locates the folder and opens it.