This example lists the top level folders in the message store, with output like:
Message store display name: Mailbox - Test User1
|-----> Calendar (0 items, 0 unread)
|-----> Contacts (0 items, 0 unread)
|-----> Deleted Items (0 items, 0 unread)
|-----> Drafts (0 items, 0 unread)
|-----> Inbox (26 items, 24 unread)
|-----> Journal (0 items, 0 unread)
|-----> Notes (0 items, 0 unread)
|-----> Outbox (9 items, 0 unread)
|-----> Sent Items (0 items, 0 unread)
|-----> Tasks (0 items, 0 unread)
The example shows how to create a session, get the message_store, get properties of the message store, and then gets the list of child folders and some associated folder properties.
#include <exception>
#include <string>
int main ()
{
try {
msg_store_props << PR_DISPLAY_NAME;
std::cout << "Message store display name: "
<< (const char*)msg_store_props[PR_DISPLAY_NAME]
<< std::endl;
for (unsigned int i = 0; i < child_folders.size(); ++i) {
child_props << PR_DISPLAY_NAME << PR_CONTENT_COUNT << PR_CONTENT_UNREAD;
std::cout << "|-----> " << (const char*)child_props[PR_DISPLAY_NAME]
<< " (" << (*(int*)child_props[PR_CONTENT_COUNT]) << " items, "
<< (*(int*)child_props[PR_CONTENT_UNREAD]) << " unread)"
<< std::endl;
}
}
{
std::cout <<
"MAPI Exception in main: " << e.
what()
<< std::endl;
}
catch (std::runtime_error e)
{
std::cout << "std::runtime_error exception in main: "
<< e.what() << std::endl;
}
return 0;
}