SelectNamesDialog.InitialAddressList Property (Outlook)

Returns or sets an AddressList object that determines the initial address list to be displayed in the Select Names dialog box. Read/write.

Version Information

Version Added: Outlook 2007

Syntax

expression .InitialAddressList

expression A variable that represents a SelectNamesDialog object.

Remarks

Setting the InitialAddressList property is the programmatic equivalent to selecting an AddressList from the drop-down list for Address Book in the Select Names dialog box.

In its default state, InitialAddressList is the AddressList that has the property AddressList.IsInitialAddressList set to True. IsInitialAddressList corresponds to setting Show this address list first in the Addressing dialog box, which is available by clicking Tools, and then Options in the Address Book dialog box.

Example

The following code sample shows how to use InitialAddressList and SelectNamesDialog.ShowOnlyInitialAddressList to have the Select Names dialog box always display only the address list in the default Contacts folder, regardless of the user's setting for the initial address list.

Sub ShowOnlyContacts() 
 
 Dim oMsg As MailItem 
 
 Set oMsg = Application.CreateItem(olMailItem) 
 
 
 
 Dim oDialog As SelectNamesDialog 
 
 Set oDialog = Application.Session.GetSelectNamesDialog 
 
 
 
 Dim oContacts As Folder 
 
 Set oContacts = _ 
 
 Application.Session.GetDefaultFolder(olFolderContacts) 
 
 
 
 Dim oAL As AddressList 
 
 For Each oAL In Application.Session.AddressLists 
 
 If oAL.GetContactsFolder = oContacts Then 
 
 Exit For 
 
 End If 
 
 Next 
 
 With oDialog 
 
 .InitialAddressList = oAL 
 
 .ShowOnlyInitialAddressList = True 
 
 .Recipients = oMsg.Recipients 
 
 If .Display Then 
 
 'Recipients Resolved 
 
 End If 
 
 End With 
 
End Sub

See Also

Concepts

SelectNamesDialog Object Members

SelectNamesDialog Object