This example lists the top level folders in the message store, with output like:
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;
}
This class represents a folder or container within Exchange.
Definition: folder.h:39
hierarchy_container_type fetch_hierarchy()
Fetch all subfolders within this folder.
std::vector< folder_shared_ptr > hierarchy_container_type
Hierarchy folders.
Definition: folder.h:58
Definition: mapi_exception.h:38
virtual const char * what() const
Definition: mapi_exception.h:48
This class represents the Message Store in Exchange.
Definition: message_store.h:46
mapi_id_t get_default_folder(const uint32_t id) const
Retrieves the folder id for the specified default folder in the Message Store.
Definition: message_store.h:72
virtual property_container get_property_container()
Obtain a property_container to be used with this object.
A container of properties to be used with classes derived from object.
Definition: property_container.h:159
uint32_t fetch()
Fetches properties with the tags supplied using operator<<.
Definition: property_container.h:178
This class represents a MAPI session with the Exchange Server.
Definition: session.h:62
message_store & get_message_store()
Obtain a reference to the message_store associated with this session.
Definition: session.h:100
void login(const std::string &profile_name="", const std::string &password="")
Log-in to the Exchange Server.