Examples: createChildEntity method

  1. This agent creates a multipart MIME entity suitable for a mail memo. The parent entity contains headers that define a Notes/Domino mail memo. Two child entities contain the content of the memo.
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here)
          Stream stream = session.createStream();
          // Do not convert MIME to rich text
          session.setConvertMIME(false);
          Database db = agentContext.getCurrentDatabase();
          Document doc = db.createDocument();
          // Create parent entity
          doc.replaceItemValue("Form", "Memo");
          MIMEEntity body = doc.createMIMEEntity();
          MIMEHeader header = body.createHeader("Content-Type");
          header.setHeaderVal("multipart/mixed");
          header = body.createHeader("Subject");
          header.setHeaderVal("MIME message");
          header = body.createHeader("To");
          header.setHeaderVal("Roberta Person");
          // Create first child entity
          MIMEEntity child = body.createChildEntity();
          stream.writeText("Text of message for child 1.\n");
          child.setContentFromText(stream, "text/plain", MIMEEntity.ENC_NONE);
          stream.truncate();
          // Create second child entity
          child = body.createChildEntity();
          stream.writeText("Text of message for child 2.");
          child.setContentFromText(stream, "text/plain", MIMEEntity.ENC_NONE);
          doc.send(false);
          // Restore conversion
          session.setConvertMIME(true);
         
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  2. This agent creates a multipart MIME entity with two child entities. The child entities are positioned in reverse order.
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here)
          Stream stream = session.createStream();
          // Do not convert MIME to rich text
          session.setConvertMIME(false);
          Database db = agentContext.getCurrentDatabase();
          Document doc = db.createDocument();
          // Create parent entity
          doc.replaceItemValue("Form", "Memo");
          MIMEEntity body = doc.createMIMEEntity();
          MIMEHeader header = body.createHeader("Content-Type");
          header.setHeaderVal("multipart/mixed");
          header = body.createHeader("Subject");
          header.setHeaderVal("MIME message");
          header = body.createHeader("To");
          header.setHeaderVal("Roberta Person");
          // Create first child entity
          MIMEEntity child = body.createChildEntity();
          stream.writeText("Text of message for child 1.\n");
          child.setContentFromText(stream, "text/plain", MIMEEntity.ENC_NONE);
          stream.truncate();
          // Create second child entity
          child = body.createChildEntity();
          stream.writeText("Text of message for child 2.");
          child.setContentFromText(stream, "text/plain", MIMEEntity.ENC_NONE);
          doc.send(false);
          // Restore conversion
          session.setConvertMIME(true);
         
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }