Extract the user's address book info

hi all,can someone tell me how to extract the user’s address book information, for example, the user’s office photo no, mobile number and so on

is that possible to show me with a sample program.

I had read thru the Domno Designer documentation, but, unfortunately, i can’t find any related information there

I really need your help

Thks

Subject: RE: Extract the user’s address book info

Terence,

In the NotesSession class, there is an AddressBooks property that can be used to retrieve the address book information you are trying to retrieve. There is an example similar to what you want to do in the Domino Designer Help database.

James Greene

Jagre Incorporated

www.jagre.net

Subject: RE: Extract the user’s address book info

hi ,Thks for ur reply.

is that the following example is the one that you are talking about, i really need help on this!

Examples: AddressBooks property

This application prints the server name (or “Local”), file name, and title of all the

Domino Directories and Personal Address Books known to the current session.

import java.util.*;

import lotus.domino.*;

class addressbooks extends NotesThread

{

public static void main(String argv)

{  

    addressbooks t = new addressbooks();

    t.start();

}

public void runNotes()

{

try

  {

    Session s = NotesFactory.createSession();

    Database db;

    Vector books = s.getAddressBooks();

    Enumeration e = books.elements();

    while (e.hasMoreElements()) 

    {

      db = (Database)e.nextElement();

      String fn = db.getFileName();

      String server;

      if (db.getServer() != null)

        server = db.getServer();

      else

        server = "Local";

      	String title = db.getTitle();

      	System.out.println(server + " " + fn + " \"" + title + "\"");

    }

}

catch (Exception e)

{

  e.printStackTrace();

}

}

}

i think this example will only prints the server name (or “Local”), file name, and title of all the Domino Directories and Personal Address Books known to the current session. instead of extracting the information from the address book

can u pls attach the portion of code or tell me which page it is from

this example is get from page 866

Thks

Subject: RE: Extract the user’s address book info

  1. 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

Subject: RE: Extract the user’s address book info

this is the code that i found from the webimport lotus.domino.*;

import java.io.PrintWriter;

public class ReadAddress extends AgentBase

{

//NotesMain method is the entry point for Domino Java Agent

public void NotesMain()

{

	try

	{

		//Create a Session object

 		Session s = this.getSession();

 		// PrintWriter object is used for output

 		

 		PrintWriter pw = this.getAgentOutput();

 		//Create a Database object; we will use the name and address book

		Database db = s.getDatabase("","names.nsf");

		//Continue only if the database was properly instantiated

		if (db != null)

		{

			//create a View object using the list of people in the NAB

			View vw = db.getView("People");

			//Continue only if the View object has been properly instantiated

			if (vw != null)

			{

				//Retrieve the first document in the view

				Document doc = vw.getFirstDocument();

				//Declare String objects to be used for field values

				String fname = null;

				String lname = null;

				int c = 0;

				//Loop through all documents in the view;

				while (doc != null)

				{

					c += 1;

					//Retrieve the contents of the FirstName and lastname field as a String

					fname = doc.getItemValueString("FirstName");

					lname = doc.getItemValueString("LastName");

					//display name and counter variable

					pw.println("Person #" + c + " : " + fname + " " + lname);

					//Get next document from the view

					doc = vw.getNextDocument(doc);

				}

				//return memory used by the View object to the system

				vw.recycle();

			}

			//Return memory used by the Database object to the system

			db.recycle();

		}

		//Return memory used by the Session object to the system

		s.recycle();

	} 

	catch(Exception e) 

	{

		e.printStackTrace();

	}

}

}

but, it gives me these 3 errors

terence@kiriya:~$ javac -cp NCSO.jar ReadAddress.java

ReadAddress.java:3: cannot find symbol

symbol: class AgentBase

public class ReadAddress extends AgentBase

                             ^

ReadAddress.java:11: cannot find symbol

symbol : method getSession()

location: class ReadAddress

                    Session s = this.getSession();

                                ^

ReadAddress.java:14: cannot find symbol

symbol : method getAgentOutput()

location: class ReadAddress

                    PrintWriter pw = this.getAgentOutput();

                                     ^

3 errors

i think it is because my NCSO.jar file don’t have the AgentBase class,

may i know why can i get a NCSO file that is come with the AgentBase class?

Subject: RE: Extract the user’s address book info

Thks for your reply and example given, but can you please show me this example in example in Java, i did search the Domino Designer 6 programming guide documentation and that is no example available. I fould like to Read the whole user address book based on user, sorry maybe i had make a mistake in my previous post, anyway, the given example, help me a lot for better understanding.hope u can get me an example of how to READ the whole address book in Java. I don’t know the Lotus Script at all. I had try to convert your code given into java, but it fails

Subject: RE: Extract the user’s address book info

These are few things that i need to do is it?1) set the diiop host ip

  1. set the diiop port

  2. set agent user name

  3. set encypt key (security key used to encrypt password in plaintext)

  4. Actual java coding that read address book information