Examples: AddressBooks property

  1. This script gets each address book, opens it, and prints its title in a dialog box.
    Dim session As New NotesSession
    Dim books As Variant
    books = session.AddressBooks
    Forall b In books
      Call b.Open( "", "" )
      Messagebox( b.Title )
    End Forall
  2. This action script finds an employee's phone number by looking it up in an Address Book. After the user enters the last name of the person, the script searches for the name in the People view of every available Domino® Directory. If a Person document is found that matches the name, the script displays the person's phone number, from the OfficePhoneNumber item on the Person document. If a matching Person document is not found in any Domino® Directory, the script displays an error message.
Sub Click(Source As Button)
  Dim session As New NotesSession
  Dim books As Variant
  Dim view As NotesView
  Dim doc As NotesDocument
  Dim done As Variant
  Dim person As String
  books = session.AddressBooks
  done = False
  person = Inputbox$ _
  ( "Enter the last name of the person: ", "Last name" )
  Forall b In books
    ' check every Domino Directory,
    ' unless we're already done
    If ( b.IsPublicAddressBook ) And ( Not done ) Then
      Call b.Open( "", "" )
      ' look up person's last name
      ' in People view of address book
      Set view = b.GetView( "People" )
      Set doc = view.GetDocumentByKey( person )
      ' if person is found, display the phone number item 
      ' from the Person document
      If Not ( doc Is Nothing ) Then
        Messagebox( "Phone for " + person  _
        + " is " + doc.OfficePhoneNumber( 0 ) )
        done = True
      End If
    End If
  End Forall
  ' if done is still False, the person wasn't found
  If Not done Then
    Messagebox _
    ( "Sorry, unable to locate person's name." )
  End If
End Sub