Using possibly complicated way to get Folder in mailbox

May 19, 2011 at 4:20 PM

Hi Stephen,

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 .

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"





May 19, 2011 at 4:35 PM

If you want, you could download the old EDK and look at the code for HrMAPIOpenFolderEx. It does basically what you describe. If you want to be more efficient, you could cache entry IDs of folder you need to get to a lot, then just open them directly when needed.

May 19, 2011 at 6:18 PM

Thanks Stephen! Will think about the caching.