Examples: createDocument method

This agent creates a new document in the current database, sets values for its Form, Subject, Categories, and Body items, and saves it.

import lotus.domino.*;
public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = 
      // (Your code goes here) 
      Database db = agentContext.getCurrentDatabase();
      Document doc = db.createDocument();
      doc.appendItemValue("Form", "Main Topic");
      doc.appendItemValue("Subject", "Test Document");
      doc.appendItemValue("Categories", "Test Documents");
      RichTextItem rti = doc.createRichTextItem("Body");
      rti.appendText("This  is the first sentence of text.");
      rti.appendText(" This is the second sentence of text.");
      if (doc.save())
        System.out.println("Document has been saved");
        System.out.println("Unable to save document");
    } catch(Exception e) {