次のエージェントは、マルチパートエンティティの最後の分岐の最後の最後からエンティティすべてを逆順で取得します。
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
// 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) {
// Drill down to end of first branch
MIMEEntity child = mime.getNextEntity(MIMEEntity.SEARCH_BREADTH);
while (child != null) {
mime = child;
child = mime.getNextEntity(MIMEEntity.SEARCH_BREADTH);
}
while (mime != null) {
System.out.println(mime.getContentAsText());
mime = mime.getPrevEntity(MIMEEntity.SEARCH_BREADTH);
}
}
else
{
System.out.println
("Not MIME - " + doc.getItemValueString("Subject"));
}
doc = dc.getNextDocument(doc);
}
// Restore conversion
session.setConvertMIME(true);
} catch(Exception e) {
e.printStackTrace();
}
}
}