例: getSomeHeaders method

次のエージェントは、現在の文書にある MIME エンティティの Subject と From ヘッダーを取得します。

import lotus.domino.*;
import java.util.Vector;

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);
      DocumentCollection dc = agentContext.getUnprocessedDocuments();
      Document doc = dc.getFirstDocument();
      while (doc != null) {
        MIMEEntity mime = doc.getMIMEEntity();
        if (mime != null) {
          System.out.println(doc.getItemValueString("Subject"));
          Vector filter = new Vector();
          filter.addElement("Subject");
          filter.addElement("From");
          System.out.println(mime.getSomeHeaders(filter, true));
        }
        else
        {
          System.out.println("Not MIME - " +
            doc.getItemValueString("Subject"));
        }
        doc = dc.getNextDocument(doc);
      }
      // Restore MIME conversion
      session.setConvertMIME(true);
     
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}