The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

AddressList.GetContactsFolder Method

Office 2007
Obtains a Folder object that represents the Contacts folder for the AddressList object.

Version Information
 Version Added:  Outlook 2007



expression   A variable that represents an AddressList object.

Return Value
A Folder object that represents the Outlook Contacts folder for the AddressList. Returns Null (Nothing in Visual Basic) if no Outlook contacts folder is found.


This method allows you to match an AddressList for the Contacts folder that you would like to set up as the initial address list in the Select Names dialog box.


The following code sample shows you how to initialize the Select Names dialog box with the AddressList for the default Contacts folder. It first obtains the Folder object for the default Contacts folder, and looks for its AddressList by comparing the Entry ID of this Folder object with the Entry ID of the Folder object assoicated with each AddressList in the current session until it finds a match. It then sets the InitialAddressList property and displays the Select Names dialog box.

Visual Basic for Applications
Sub SetContactsFolderAsInitialAddressList()
    Dim oMsg As MailItem
    Set oMsg = Application.CreateItem(olMailItem)
    Dim oDialog As SelectNamesDialog
    Set oDialog = Application.Session.GetSelectNamesDialog
    Dim oAL As AddressList
    Dim oContacts As Folder
    Set oContacts = _
    On Error GoTo HandleError
    'Look for the AddressList for the default Contacts folder
    For Each oAL In Application.Session.AddressLists
        If oAL.AddressListType = olOutlookAddressList Then
            If oAL.GetContactsFolder.EntryID = _
                oContacts.EntryID Then
                Exit For
            End If
        End If
    With oDialog
        .Caption = "Select Customer Contact"
        .ToLabel = "Customer C&ontact"
        .NumberOfRecipientSelectors = olShowTo
        .InitialAddressList = oAL
        'Let the selected names be the recipients of the new message
        .Recipients = oMsg.Recipients
        If .Display Then
            'Recipients Resolved
        End If
    End With

    Exit Sub
End Sub

Community Additions