Reading Mail
Assuming that a MAPI session has been established, reading mail is comprised of the following steps.
Traverse the CDO object hierarchy to find a message of interest.
Read the Message object’s properties to retrieve message information.
As explained in Chapter 5, message stores are databases that store messages. The user’s MAPI profile controls which message stores are available to the user. In CDO, a message store is represented by an InfoStore object. The Session object has an InfoStores collection, which in turn has one InfoStore object for each message store set up in the user’s profile. To discover what message stores exist for a user, iterate through the InfoStores collection. You’ll see an example of this in a moment.
Within each message store is a folder tree. To represent this in CDO, each InfoStore object has a RootFolder property, which contains a reference to a Folder object that acts as the root of the folder tree for that message store. The root Folder object doesn’t contain messages—only additional folders. The Folders property of the root Folder object references a collection of more Folder objects, each of which can contain a reference to another Folders collection as well as a reference to a Messages collection. The Messages collection has one Message object for each message in the folder. In this way, the MAPI folder hierarchy can be traversed using the CDO object hierarchy.
Example 6-2, taken from this chapter’s sample application, shows how ...
Get CDO & MAPI Programming with Visual Basic: now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.