How to: List the Name and Office Location of Each Manager Belonging to an Exchange Distribution List
Outlook Developer Reference |
This topic describes how to allow a user to select an Exchange distribution list and display the name and office location of each member who is a manager belonging to that distribution list. The major steps of this procedure are as follows:
The code sample below displays a Select Distribition List dialog box for the user to select a distribution list.
It uses the SelectNamesDialog object to display the dialog box and obtain user selection. The sample then obtains the user selection through the SelectNamesDialog.Recipients property.
For each member in the selected distribution list:
If the member is a manager, then the code sample displays the name and office number of the manager.
Each member in the distribution list is an AddressEntry object. By checking if the AddressEntry.AddressEntryUserType is either olExchangeUserAddressEntry or olExchangeRemoteUserAddressEntry, the sample then assigns the AddressEntry object to an ExchangeUser object, and uses
ExchangeUser.GetDirectReports.Count >0
as a criterion to determine if the user is a manager. It then displays the Name and OfficeLocation properties of the ExchangeUser object.If the member is a distribution list, the code sample calls the subroutine
EnumerateDLManagers
. For each member in that distribution list, if the member is a manager, the code sample then displays the name and office number of the manager.
Copy the following Visual Basic for Applications code sample to the Visual Basic Editor, and run ShowManagersOfGroups
. Note that this code sample only applies to a distribution list that has only Exchange users as members, or that has Exchange distribution lists as members but all members of the latter will have to be Exchange users. Further customization of the code will be necessary if there is more nesting of distribution lists as members.
|