Chapter 10. Contacts Folders

Contacts folders are an abstraction provided not by MAPI or CDO, but by Microsoft Outlook. To MAPI and CDO, a contact is just a message that happens to have certain properties useful for storing contact-related information. Because CDO doesn’t provide a class that exposes contact properties, it’s difficult to get at all of the contact information. This is the same problem that we had with tasks folders in the previous chapter. However, unlike with tasks, MAPI does define many standard property tags for storing and accessing contact information. These MAPI property tags can be used in conjunction with a CDO Field object to store and retrieve contact data. Just as with task items, however, some contact item properties can’t be accessed reliably through CDO because they are exposed as named properties. You learned why this is a problem in the previous chapter.

This chapter discusses the basic contact information that is available through a Message object and shows how to get additional contact information by going through a Field object. Also discussed is using the MessageFilter object to search for specific contacts.

Finding the Default Contacts Folder

A user can have any number of contacts folders, but one of them (the one created first) is considered to be the default contacts folder. CDO provides a simple way to get access to the default contacts folder. To do so, use the Session object’s GetDefaultFolder method, with an argument of CdoDefaultFolderContacts ...

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.