|
|
To pop up the Select Names dialog
The Select Names dialog that users see when they click the To
button in an Outlook message is available to programmers, but not
through the Outlook object model. Instead, you must use
Collaboration Data Objects (CDO). Note that
CDO is not installed by default in Outlook 2000 and is removed from
Outlook 98 by the Outlook E-mail
Security Update.
The two VBScript samples below use the CDO
AddressBook method to allow the user (a) to choose several addresses
and put them in a mail message and (b) to return a single name. Both
have code to handle the error that will occur if the
Outlook E-mail
Security Update is installed and the user does not click Yes at
the address book security prompt. To completely avoid the security
prompts, you can use
Redemption, which has a similar method but triggers no prompts.
Put Addresses in a Message
| Return a Single Name
| Notes | More Information
|
Put Addresses in a Message
The
following VBScript code sample allows the user to select names, then
puts them into the e-mail message passed to the procedure as the
objMail argument:

|
Return a Single Name
The following script returns a single name from the address book and
warns the user if more than one name was selected:

|
Notes
The
AddressBook method provides many options, including setting the number
of recipient "wells" and their titles. The two
examples above use only one "well." See
AddressBook method for more details.
While Microsoft officially does not support the use of CDO with
Outlook running in Internet
Mail Only mode, generally there is no problem. One exception is
that you cannot use the oneAddress parameter in IMO mode; doing
so will generate an error.
Both samples above include error-handling for
the case in which the user cancels the address book dialog and the
case in which the user has the Outlook Email Security Update installed and responds No to the
e-mail address access dialog.
In the second sample, the name returned may
include text such as "(E-mail)." This will depend on which address
book the name was selected from and the Outlook version. You may want to edit the name to
remove that kind of information, using standard text-parsing
functions.
|
More Information
|
|
|