顯示通訊錄中的名稱
這個主題會說明通訊錄,並解釋如何以程式的方式在 [Outlook 通訊錄] 對話方塊中顯示通訊錄中的名稱。
Outlook 會維護工作階段的通訊錄階層。 In order for the transport provider to deliver a message, the recipient must have an address entry in one of the address books in this hierarchy.
An address book contains one or more address lists. Each address list is composed of users, distribution lists, or other types of address entries. An example of an address list is the Exchange Global Address List. In the Outlook user interface, you can open the Address Book dialog box to view and select names in an address list. When you create a mail item or appointment item, or when you assign a task item, you can use the Address Book to help you select recipients.
The Outlook Address Book is an address list or a set of address lists that Outlook creates automatically. 根據預設,它包含 [連絡人] 資料夾中至少有一個電子郵件地址或傳真號碼專案的連絡人地址清單。 As you create other folders in the Contacts module, by default, each folder will also become an address list in the Outlook Address Book. 在資料夾 [內容] 對話方塊的 [Outlook 通訊錄] 索引標籤中,您可以選取或取消選取[將此資料夾顯示為電子郵件通訊錄]。
從可程式性的觀點來看,Outlook 會維護目前會話的 AddressLists 集合。 Each AddressList consists of a collection of AddressEntries. OlAddressListType) 列舉的地址清單 (不同類型,以及OlAddressEntryUserType) 列舉的不同位址專案類型 (。 當您將資料夾新增至連絡人模組時,可以使用 Folder.ShowAsOutlookAB 來指定該資料夾是否會在 Outlook 通訊錄中顯示為通訊清單。
Recipient物件與Recipient.Address屬性所指定的AddressEntry物件相關聯。 您也可以使用 AddressEntry.AddressEntryUserType 屬性來識別收件者的類型,例如,收件者是連絡人項目、Exchange 使用者或 Exchange 通訊群組清單。
SelectNamesDialog物件可讓您在類似 Outlook 使用者介面中 [選取名稱] 對話方塊的對話方塊中顯示地址清單中的名稱。 The following figure is an example of the Select Names dialog box displaying the Contacts folder.
對話方塊可讓使用者從通訊錄中的一或多個通訊清單中選取專案,並傳回 SelectNamesDialog.Recipients 屬性中選取的收件者。 透過 SelectNamesDialog 的屬性及方法,您可以控制對話方塊的下列層面:
對話方塊中最初顯示的通訊清單,以及是否只顯示這個通訊清單。
The number of recipient selectors, for example, whether to show all three labels of To, Cc, and Bcc.
The strings representing the title, To, Cc, and Bcc labels where applicable. Long titles and labels will be truncated without resizing the width of the dialog box.
使用者是否可以同時選取一個或多個地址項目。
關閉對話方塊之前是否要解析收件者名稱。
如果沒有解析全部收件者,要執行的動作。
若要對話方塊中顯示通訊清單中的名稱:
使用Application.Session) 所指示之目前會話 (的 GetSelectNamesDialog方法,取得目前會話的SelectNamesDialog物件實例。
使用目前工作階段的 AddressLists 屬性取得目前工作階段的 AddressLists 集合。
根據預設,對話方塊會以 AddressList.IsInitialAddressList 設為 True的地址清單初始化。 在必要時,您可以使用 SelectNamesDialog.InitialAddressList ,在步驟 2 中以 AddressLists 集合的另一個 AddressList 來初始化對話方塊。
使用 SelectNamesDialog.Display 顯示對話方塊。 這個方法會根據SelectNamesDialog.ForceResolution和使用者的回應傳回True或False:
- 如果已設定SelectNamesDialog.ForceResolution、解析所有選取的名稱,且使用者按一下 [確定],則此方法會傳回True。
如果已設定SelectNamesDialog.ForceResolution,但並非所有收件者都已解析,則會傳回False。
如果未設定 SelectNamesDialog.ForceResolution且使用者按一下 [確定],則會傳回False。
如果使用者按一下[取消] 或 [關閉] 圖示,則會傳回False。
- 如果 SelectNamesDialog.Display 傳回 True,請使用 SelectNamesDialog.Recipients取得選取的位址專案。
另請參閱
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。