Examples: createMIMEEntity method

This agent creates a mail message in MIME format.

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();
      session.setConvertMIME(false); // Do not convert MIME to RT
      Database db = agentContext.getCurrentDatabase();
      Document doc = db.createDocument();
      doc.replaceItemValue("Form", "Memo");
      MIMEEntity body = doc.createMIMEEntity();
      header = body.createHeader("Subject");
      header.setHeaderVal("MIME message");
      header = body.createHeader("To");
      header.setHeaderVal("Roberta Person");
      stream.writeText("Text of message.");
      body.setContentFromText(stream, "text/plain;charset=UTF-8",
        MIMEEntity.ENC_NONE);
      doc.send(false);
      session.setConvertMIME(true); // Restore conversion
    
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}