例: setHeaderVal method

次の例では、マルチパート MIME エンティティが作成され、必要に応じてヘッダー値が設定されます。

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();
    }
  }
}