Platform SDK: CDO 1.2.1 |
The AddressBook method displays a modal dialog box that allows the user to select entries from the address book. The selections are returned in a Recipients collection object.
Set objRecipients = objSession.AddressBook( [recipients] [, title] [, oneAddress] [, forceResolution] [, recipLists] [, toLabel] [, ccLabel] [, bccLabel] [, parentWindow ] )
recipLists setting |
Action |
---|---|
–1 | Displays three list boxes with default captions and without resolution, that is, acts as a shortcut for forceResolution=False, recipLists=3 with no setting of toLabel, ccLabel, or bccLabel. |
0 | Displays no list boxes. The user can interact with the address book dialog box but no recipients are returned by this method. |
1 | Displays one list box for CdoTo recipients (default). |
2 | Displays two list boxes for CdoTo and CdoCc recipients. |
3 | Displays three list boxes for CdoTo, CdoCc, and CdoBcc recipients. |
The AddressBook method returns CdoE_USER_CANCEL if the user cancels the dialog box.
The recipients parameter provides initial values for the recipient list boxes. These values expedite the user’s recipient selection process. A common use of this parameter is to set it to the Recipients collection of a message to which you are generating a reply.
When you use AddressBook to let the user select recipients for a new message, you use either two or three different Recipients collections, depending on whether you furnish the recipients parameter. Use the following procedure:
Set objNewMessage.Recipients = objRecipients objNewMessage.Recipients.Resolve ' also updates everything
The oneAddress parameter indicates whether only one address entry at a time can be selected before being added to the recipients list. If oneAddress is set to False, the user can select multiple recipients by using the CTRL or SHIFT key during the selection. If oneAddress is set to True, multiple selection is disabled.
To provide an access key for the recipient list boxes, include an ampersand (&) character in the label argument string, immediately before the character that serves as the access key. For example, if toLabel is “Local &Attendees:”, users can press ALT+A to move the focus to the first recipient list box.
The address book dialog box is always modal, meaning the parent window is disabled while the dialog box is active. If the parentWindow parameter is set to zero or is not set, all windows belonging to the application are disabled while the dialog box is active. If the parentWindow parameter is supplied but is not valid, the call returns CdoE_INVALID_PARAMETER.
The following methods can invoke dialog boxes:
However, if your application is running as a Microsoft® Windows NT® service, for example from Active Server Pages (ASP) script on a Microsoft® Internet Information Server (IIS), no user interface is allowed.
For more information on running as a service, see "Windows NT Service Client Applications" in the MAPI Programmer's Reference under Guide, Introduction to MAPI Programming, Operating Environment Issues.
This code fragment displays an address book dialog box labeled “Select Attendees” with three recipient lists:
If objSession Is Nothing Then MsgBox "Must first create MAPI session and log on" Exit Function End If Set objRecipColl = objSession.AddressBook( _ Title:="Select Attendees", _ forceResolution:=True, _ recipLists:=3, _ toLabel:="&Very Important People", _ ' on button ccLabel:="&Fairly Important People", _ bccLabel:="&Secret Important People") ' "recipients:=" parameter not used in preceding call MsgBox "Name of first recipient = " & objRecipColl.Item(1).Name ' could be objRecipColl(1) since Item and Name are default properties Exit Function