Examples: setBegin method

This agent gets the text of the second paragraph.

import lotus.domino.*;

public class JavaAgent extends AgentBase {

  public void NotesMain() {

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

      // (Your code goes here) 
      DocumentCollection dc = agentContext.getUnprocessedDocuments();
      Document doc = dc.getFirstDocument();
      RichTextItem body = (RichTextItem)doc.getFirstItem("Body");
      RichTextNavigator rtnav = body.createNavigator();
      if (rtnav.findNthElement(
      RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH, 2)) {
        RichTextRange rtrange = body.createRange();
        rtrange.setBegin(rtnav);
        System.out.println(rtrange.getTextParagraph());
      }
      else
        System.out.println("Body does not have 2nd paragraph");

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