Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

AddressList.GetContactsFolder Method

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

Version Information
 Version Added:  Outlook 2007

Syntax

expression.GetContactsFolder

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.

Remarks

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.

Example

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 = _
        Application.Session.GetDefaultFolder(olFolderContacts)
    
    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
    Next
      
    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

HandleError:
    Exit Sub
End Sub



Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.