Examples: BoundaryEnd property

This agent displays the start and end boundaries of the end-child entities in a multipart entity.

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) {
        System.out.println("Subject:\t\t" +
        doc.getItemValueString("Subject"));
        MIMEEntity mime = doc.getMIMEEntity();
        if (mime != null) {
          // If multipart MIME entity
          if (mime.getContentType().equals("multipart")) {
            // Print preamble
            if (!mime.getPreamble().equals("")) {
              System.out.println("Preamble:\t" + mime.getPreamble());
            }
            // Print content of each child entity
            MIMEEntity child1 = mime.getFirstChildEntity();
            while (child1 != null) {
              //System.out.println("*Content of child*");
              System.out.println(child1.getBoundaryStart() +
                child1.getContentAsText() +
                child1.getBoundaryEnd());
              MIMEEntity child2 = child1.getFirstChildEntity();
              if (child2 == null) {
                  child2 = child1.getNextSibling();
                if (child2 == null) {
                  child2 = child1.getParentEntity();
                  if (child2 != null)
                    child2 = child2.getNextSibling();
                }
              }
              child1 = child2;
            }
          }
          // If not multipart, just print content
          else {
            System.out.println(mime.getContentAsText());
          }
        }
        else {
          System.out.println("Not MIME");
        }
        doc = dc.getNextDocument(doc);
      }
      // Restore conversion
      session.setConvertMIME(true);
     
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}