Examples: getPrevSibling method (MIMEEntity - Java)

This agent gets all the MIME entities at the last level of the first branch 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.getFirstChildEntity();
          while (child != null) {
            mime = child;
            child = mime.getFirstChildEntity();
          }
          MIMEEntity sibling = mime.getNextSibling();
          while (sibling != null) {
            mime = sibling;
            sibling = mime.getNextSibling();
          }
          while (mime != null) {
            System.out.println(mime.getContentAsText());
            mime = mime.getPrevSibling();
          }
        }
        else
        {
          System.out.println("Not MIME - " + 
          doc.getItemValueString("Subject"));
        }
        doc = dc.getNextDocument(doc);
      }
      // Restore conversion
      session.setConvertMIME(true);
     
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}