次のエージェントは、文書内の 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) {
String m = "Content type: " + mime.getContentType() + "¥n" +
"Content subtype: " + mime.getContentSubType() + "¥n" +"Character set: " + mime.getCharset() + "¥n" +"Encoding: " + mime.getEncoding();
System.out.println(doc.getItemValueString("Subject") + "¥n" + m);
System.out.println(mime.getHeaders());
System.out.println(mime.getContentAsText());
}
else
{
System.out.println("Not MIME - " +
doc.getItemValueString("Subject"));
}
doc = dc.getNextDocument(doc);
}
// Restore conversion
session.setConvertMIME(true);
} catch(Exception e) {
e.printStackTrace();
}
}
}