Examples: findFirstString method

This agent finds the first occurrence of a search string in the Body item of the current or first selected document.

import lotus.domino.*;

public class JavaAgent extends AgentBase {

  public void NotesMain() {

    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();

      // (Your code goes here) 
      String searchString = "foo";
      DocumentCollection dc = agentContext.getUnprocessedDocuments();
      Document doc = dc.getFirstDocument();
      RichTextItem body = (RichTextItem)doc.getFirstItem("Body");
      RichTextNavigator rtnav = body.createNavigator();
      RichTextRange rtrange = body.createRange();
      if (rtnav.findFirstString(searchString,
      RichTextItem.RT_FIND_CASEINSENSITIVE)) {
        rtrange.setBegin(rtnav);
        System.out.println(rtrange.getTextParagraph());
      }
      else
        System.out.println("String not found");

    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}