This example displays information about the messages in the inbox, with output like:
This example displays information about the messages in the inbox, with output like:
Inbox contains 2 messages
|-----> Test User1 | Working Remotely with Windows Small Business Server
|-----> Test User1 | Welcome to Windows Small Business Server 2003
The example shows how to create a session, get the message_store, and open the inbox folder. It then determines how many messages are in the inbox folder, and retrieves and prints the intended addressee and the message subject.
#include <exception>
#include <string>
int main ()
{
try {
std::cout << "Inbox contains " << messages.size() << " messages" << std::endl;
for (unsigned int i = 0; i < messages.size(); ++i) {
msg_props << PR_DISPLAY_TO << PR_CONVERSATION_TOPIC;
if (msg_props[PR_DISPLAY_TO] != 0) {
std::cout << "|-----> " << (const char*)msg_props[PR_DISPLAY_TO];
if(msg_props[PR_CONVERSATION_TOPIC] != 0) {
std::cout << "\t\t| " << (const char*)msg_props[PR_CONVERSATION_TOPIC];
}
std::cout << 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
message_container_type fetch_messages()
Fetch all messages in this folder.
std::vector< message_shared_ptr > message_container_type
Definition: folder.h:46
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
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.