Examples: Directory class

This agent prints the name of every person whose email address in the local directory contains the name John.

import lotus.domino.*;
public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();
      // (Your code goes here) 
      Directory dir = session.getDirectory(null);
      String server = dir.getName();
      if (server.equals("")) server = "Local";
      System.out.println ("People named John on server " 
         + server + "\n");
      DirEntryCollection direc = dir.lookupNames("Contacts","John","email");
      DirEntry dirent = direc.getFirstEntry()
      while (dirent != null) {
        String name = dirent.getItemValue("Name");
        System.out.println(name);
        dirent = direc.getNextEntry(); }
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}