Examples: setCharOffset method

This agent gets the first text paragraph starting at the ninth character.

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.findFirstElement(RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH)) {
        rtnav.setCharOffset(8);
        RichTextRange rtrange = body.createRange();
        rtrange.setBegin(rtnav);
        System.out.println(rtrange.getTextParagraph());
      }
      else
        System.out.println("No text in Body item");

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