例: Encoding property

次のエージェントは、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"));
          String enc = "";
          switch (mime.getEncoding()) {
            case MIMEEntity.ENC_BASE64 : enc = "base64"; break;
            case MIMEEntity.ENC_EXTENSION : enc = "Extension"; break;
           case MIMEEntity.ENC_IDENTITY_7BIT : enc = "7bit"; break;
           case MIMEEntity.ENC_IDENTITY_8BIT : enc = "8bit"; break;
           case MIMEEntity.ENC_IDENTITY_BINARY : enc = "binary"; break;
           case MIMEEntity.ENC_NONE : enc = "None"; break;
           case MIMEEntity.ENC_QUOTED_PRINTABLE : enc = "quoted-printable";
          }
          System.out.println("Encoding = " + enc);
        }
        else
        {
          System.out.println("Not MIME - " +
            doc.getItemValueString("Subject"));
        }
        doc = dc.getNextDocument(doc);
      }
      // Restore conversion
      session.setConvertMIME(true);
     
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}