例: Charset property (MIMEEntity - Java™)

次のエージェントは、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);
      DocumentCollection dc = agentContext.getUnprocessedDocuments();
      Document doc = dc.getFirstDocument();
      while (doc != null) {
        MIMEEntity mime = doc.getMIMEEntity();
        if (mime != null) {
          System.out.println(doc.getItemValueString("Subject"));
          if (mime.getContentType().equals("text")) {
            System.out.println("Character set is " + mime.getCharset());
          }
          else
          {
            System.out.println("Not text");
          }
        }
        else
        {
          System.out.println("Not MIME - " + 
            doc.getItemValueString("Subject"));
        }
        doc = dc.getNextDocument(doc);
      }
      // Restore conversion
      session.setConvertMIME(true);
     
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}