Examples: endSection method

This agent creates a new document whose Body item is a section containing the Body item of the 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) 
      DocumentCollection dc = agentContext.getUnprocessedDocuments();
      Document doc = dc.getFirstDocument();
      Database db = agentContext.getCurrentDatabase();
      Document newdoc = db.createDocument();
      newdoc.appendItemValue("Form", "MainTopic");
      newdoc.appendItemValue("Subject", "New document with attachment");
      RichTextItem rti = newdoc.createRichTextItem("Body");
      rti.beginSection(doc.getItemValueString("Subject"));
      RichTextItem body = (RichTextItem)doc.getFirstItem("Body");
      rti.appendRTItem(body);
      rti.endSection();
      newdoc.save(true, true);
        

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

}