Domino Connection : Accessing the mail system : Understanding mail : Using the names and address book
Using the names and address book
The best source for valid address information is the names and address book. Typically you have a local names and address book on your workstation and one or more address books on the servers. Depending on your Domino installation's domain concept you may have access to one or more of those databases. There is a method to find out about the existence of names and address books on every machine you can connect to. Use the AbtLnConnection method addressBookNames to receive an OrderedCollection of database path names.
After selecting one address book, you can retrieve data from different views, depending on your addressing scheme. The following code sample gives you an impression on how to access mail addresses on a mail server.
Note:
You have to have at least "reader" access to your names and address book to perform the following sample code successfully.
 
| connection namesAndAddressBook addressView
itemName columnDescription validNames viewNote |
"Startup runtime system"
AbtLnEnvironment startUp.
"Create a connection to your mail server"
connection := AbtLnConnection mailServer.
"Open the first of the available Name and Address books on the mailserver"
namesAndAddressBook := connection
openDatabase: (connection
addressBookNames first).
"Retrieve a view note"
viewNote := namesAndAddressBook viewNoteByName: 'People'.
"Open the corresponding view"
addressView := namesAndAddressBook openViewNoUpdate: viewNote title.
"Find the column that contains address information"
columnDescription := viewNote columnFormats detect: [ :column |
column title = 'E-Mail' ] ifNone: [nil].
"Find out the internal name of the item displayed in the address
column"
columnDescription isNil
ifFalse: [ itemName := columnDescription itemName ].
"Return a list of valid recipients, that is the contents of the
address column"
validNames := addressView root children collect: [ :pseudoNote |
pseudoNote pseudoNote at: itemName ].
"Print the names with domain information on the Transcript window"
validNames do: [ :name |
Transcript nextPutAll: name;cr.].
"Clean up open handles. Close view and database"
addressView close.
namesAndAddressBook close.
"Shut down runtime system"
AbtLnEnvironment shutDown.
The variable 'validNames' contains an OrderedCollection of Strings which represent full mail address definitions (First Name, Name, MailDomain). If you need an other address format you can select other columns from other views.
You do not have to pick your recipients from the names and Address book, you can set the recipients field to any String if you are sure about the address. Domino Connection offers a special class to access cached address information from the Domino names & address book to verify that certain recipients can be reached. The class is called AbtLnNameLocator. To operate the locator you have to get used to two more classes: AbtLnNameSpace and AbtLnLookupResult. The name locator is capable of finding out information which is present in certain views of names and address books on any server you can reach. The locator must be configured with one or more namespaces (which kind of represent views in a name and address book) and a domain (which represents a Domino server, not to confuse with Mail domains). You can then pass one or more intended recipients to the locator and send the lookup message. The locator returns a collection of AbtLnLookupResults which can be queried for some details about the found names and address book entries.
Here is a step-by-step example how to find out about your own names and address book entry on your mail server:
| locator nameSpace |
"Start runtime system"
AbtLnEnvironment startUp.
"Instantiate a locator on your mail server"
locator := AbtLnNameLocator new
domain: AbtLnConnection mailServer server.
"Configure the locator with the User namespace and specify details to
be checked"
locator addNameSpace:
(AbtLnNameSpaceUser new
fullName;
mailAddress;
mailFile;
shortName).
"Set your user name to be checked by the locator"
locator find: AbtLnEnvironment currentUserName.
"Run the locator and print results on the Transcript window"
locator lookup do: :lookupResult |
Transcript nextPutAll: lookupResult printString ].
"Shutdown runtime system"
AbtLnEnvironment shutDown.
This function is very useful if you want to have quick access to names and address information. It is much faster that opening a view and you can search on a number of address books on one server at a time.
Last modified date: 01/29/2015