Exposing Folders in Message Stores

Every message store provider must present a top-level IMAPIFolder object to client applications. The top-level folder corresponds to the entire message store; it provides access to the folders that users see as the contents of the message store. In addition, the top-level folder is often used as the default receive folder for IPC messages and as the folder from which read reports are sent. Message store providers must also present an IPM subtree — a set of folders used to contain IPM messages — to client applications.

Client applications can open the top-level folder by calling IMsgStore::OpenEntry with 0 and NULL for the cbEntryId and lpEntryId parameters. In most cases, however, client applications open the set of folders containing IPM messages.

    To get a list of folders in the message store's IPM folder tree
  1. Use your MAPI session to call the IMAPISession::OpenMsgStore method.
  2. Use the resulting message database pointer to call the IMAPIProp::GetProps method for the PR_IPM_SUBTREE_ENTRYID property.
  3. Call the IMsgStore::OpenEntry method with the entry identifier to get an IMAPIFolder pointer.
  4. Call the IMAPIContainer::GetHierarchyTable method to get a table of the contents of the folder.
  5. Call the IMAPITable::QueryRows method to list the folders in the top-level folder.

MAPI clients use these folders to access other folder objects and message objects in the message store. IMAPIFolder, and its parent interface IMAPIContainer, contain the methods your message store provider must implement to populate folders with message objects and respond to clients' requests to operate on messages.