共用方式為


Outlook) (AddressList.GetContactsFolder 方法

會取得 Folder 物件,代表 AddressList 物件的 Contacts 資料夾。

語法

expressionGetContactsFolder

表達 代表 AddressList 物件的變數。

傳回值

Folder 物件,表示 AddressList 的 Outlook [連絡人] 資料夾。 如果找不到 Outlook [連絡人] 資料夾,就會傳回 Null (在 Visual Basic 中則是 Nothing)。

註解

這個方法可讓您比對 [連絡人] 資料夾的 AddressList ,您想要在 [ 選取名稱 ] 對話方塊中設定為初始通訊清單。

範例

下列程式碼範例將示範如何使用預設 [連絡人] 資料夾的 AddressList 來初始化 [選取名稱] 對話方塊。 它會先取得預設 [連絡人] 資料夾的Folder物件,並藉由比較此Folder物件的專案識別碼與目前會話中每個 AddressList 相關聯之 Folder物件的專案識別碼來尋找其AddressList,直到找到相符專案為止。 然後設定 InitialAddressList 屬性,並顯示 [ 選取名稱 ] 對話方塊。

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

另請參閱

AddressList 物件

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應