Below are some examples for using the Contact List in Outlook. Before you can use these example you must set a reference to the Outlook Object Library.
The CreateItem method is used to create the new contact. This method can be used to create just about anything in Outlook; Emails, Tasks, Journal Entries, etc. olContactItem is a built in constant that tells VBA which type of item to create.
The With/End With block shows some typical properties that can be set for a ContactItem object. Note that to add multiple Categories, which takes a String data type, pass a comma delimited list.
The .SelectedMailingAddress property is set using a built-in constant, olHome. The other options are olBusiness, olOther, and olNone. Note that if you use late binding, you must convert any built-in constants that you use to their numeric equivalent.
Don't forget to .Save, or at least .Display, before your procedure completes.
The NameSpace object isn't a typical object. There is no physical representation of the NameSpace as there is for a Folder or an AppointmentItem. It serves as a gateway for access to much of the objects in Outlook's object model. To get at the NameSpace, you use the GetNameSpace method of the Application object. The only argument that is supported for this method is "MAPI", so that makes it nice and easy.
The Folder object represents actual folders in Outlook. To see these folders, choose Folder List from the View menu in Outlook. Outlook provides a method of the NameSpace object called GetDefaultFolder. The GetDefaultFolder method is useful when you need a reference to a default folder quickly. Sometimes you need to get a folder that isn't a default folder, and that's when nesting Folders properties as in the example above does the trick. You can, however, start with a default folder to reference folders beneath it in the folder hierarchy, as in this example:
Set Fldr = olNs.GetDefaultFolder(olFolderContacts).Folders("SecretStuff")
The meat of the procedure simply uses a For Each statement to loop through all of the ContactItems in the Folder. When it finds one that satisfies the criteria, it prints certain properties to the Immediate Window. This example tests for a NickName of "DoubleD". You can test for whatever properties that suit your situation. Also, once the object variable, olCi, points to the correct ContactItem, you can do anything you want to it. You can write its properties to cells or even change its properties. If you change anything, be sure to use the .Save method or you will be disappointed.