I followed the MFCMAPI app to write code to return a folder, several subfolders down in my mailbox. I wanted to show my steps to see if my interpretation of the method is correct. Perhaps also there is a more efficient way of doing this:
I've done some unit testing and can see that I am at least going down through the directories. We expect users to always have the same directory setup.
To Get OpenMsgStore for "Public Folders"
MapilogonEx,QueryRows- get Entry ID, OpenMsgStore (get LPMDB lpMDB) for "Public Folders" folder using Entry ID as input .
To Get to IPM_SUBTREE
Call OpenEntry using lpMDB, GetHierarchyTable, set Columns for Hierarchy, QueryRows on Hierarchy table, get Entry id
for this level.
To Get to a child directory
Call OpenEntry using lpMDB and Entry Id of parent folder, GetHierarchyTable, set Columns for Hierarchy,
QueryRows on Hierarchy table
To return folder
OpenEntry using m_lpContainer and current Entry Id. Check if container is of folder type
and lpFolder = (LPMAPIFOLDER)m_lpContainer;
In the old MS Exchange 5.5 we had
HrMAPIOpenFolderEx(lpMDB, '\\', pszFullFolderPath, &lpFolder); - We could retrieve a folder specified at a relative path from "Public Folders"