Examples: getPrevEntity method
This agent gets all the entities from the end of the end of last branch of a multipart entity in reverse order.
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();
}
}
}