libmapi++ provides C++ bindings for OpenChange client libraries (libmapi). It is intended to provide a higher level abstraction of the OpenChange client libraries for C++ users who would prefer to work with an object-oriented API.
When using libmapi++, you start by creating a session, and logging in to the server.
The session can then access the message store, which is the tree of private folders associated with a single user (containing various folders, such as the Inbox, Sent Mail, Calendar, Journal and so on).
The message store is associated with the session, so you don't create it yourself. Instead, you obtain it using the session object's get_message_store() method.
Most objects in libmapi++ (and any kind of MAPI library) can be considered to have properties that belong to them, and subordinate (child) objects. For example, the name of the message store is a property of the message store, but the various folders in the message store (or equally, the messages in a folder, or the attachments to a message) are part of a hierachy.
To get access to the properties of an object, you obtain the property_container associated with the object, set the properties you want to access, call fetch(), and then read off the various properties.
Note that the operator[] is essentially a lookup operator. If you'd prefer to use an iterator, look at libmapipp::property_container_iterator.
As noted above, the objects in libmapi++ can be considered as a hierachy. To get the child elements for an object, you use the hierachy table for that element. For example, to get the various folders in the private information store, you could use code like this:
As an alternative to working through the folder tree hierachy, you can also open folders directly. In the example below, we open the Inbox. The API documentation for message_store::get_default_folder() provides a list of other folder IDs that you may find useful.
You can then get each message in the folder:
You can then get the various properties of each message in the same way as was used for the folder properties - you get the associated property_container, set the required properties, and call fetch() before reading off the required properties:
![]() ![]() ![]() |
This content is licensed under the Creative Commons Attribution ShareAlike License v. 3.0: http://creativecommons.org/licenses/by-sa/3.0/ |