Skip to Content
CDO & MAPI Programming with Visual Basic:
book

CDO & MAPI Programming with Visual Basic:

by Dave Grundgeiger
October 2000
Intermediate to advanced
384 pages
10h 22m
English
O'Reilly Media, Inc.
Content preview from CDO & MAPI Programming with Visual Basic:

Reading Contact Information

Reading basic information from a contact item is just like reading a message. Contact items are represented by Message objects, which reside in Messages collections contained in Folder objects. The code in Example 10-1 shows how to iterate through the contact items found in the user’s Contacts folder.

Example 10-1. Iterating Contacts

' gCdoSession previously Dim'ed, Set, and logged on.

Dim CdoFolder As MAPI.Folder
Dim CdoMessages As MAPI.Messages
Dim CdoMessage As MAPI.Message

' Get the collection of contact items from the Contacts folder.
Set CdoFolder = gCdoSession.GetDefaultFolder(CdoDefaultFolderContacts)
Set CdoMessages = CdoFolder.Messages

' Loop for each contact.
For Each CdoMessage In CdoMessages
   '
   ' Process the contact item.
   '
Next CdoMessage

' Cleanup
Set CdoMessage = Nothing
Set CdoMessages = Nothing
Set CdoFolder = Nothing

All of the standard Message object properties can be used with contact items. Note that the Subject property of the Message object is set to the name of the contact, and the Type property of the Message object is set to "IPM.Contact“.

In addition to the properties exposed by the Message object, standard MAPI contact item-related properties can be accessed through the Message object’s Fields collection.

The process for getting or setting a MAPI property using the Fields collection is:

  1. Obtain a reference to the Fields collection of the CDO object whose property is to be read or written.

  2. From the Fields collection, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Excel® 2007 VBA Programmer's Reference

Excel® 2007 VBA Programmer's Reference

John Green, Stephen Bullen, Rob Bovey, Michael Alexander
COM Programming with Microsoft® .NET

COM Programming with Microsoft® .NET

John Paul Mueller, Julian Templeman

Publisher Resources

ISBN: 156592665XSupplemental ContentCatalog PageErrata