JAVA/CORBA CLASSES


Examples: createParentEntity method
This agent gets the MIME entity in the current document. If the entry is not multipart, the agent creates a parent entity. The agent then appends a child 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) {
       MIMEEntity mime = doc.getMIMEEntity();
       MIMEEntity parent;
       if (mime != null) {
         if (!mime.getContentType().equals("multipart")) {
           parent = mime.createParentEntity();
         }
         else {
           parent = mime;
         }
         mime = parent.createChildEntity();
         stream.writeText("Additional text.\n\n");
         mime.setContentFromText(stream, "text/plain", MIMEEntity.ENC_NONE);
         doc.save(true, true);
       }
       else
       {
         System.out.println("Not MIME - " +
         doc.getItemValueString("Subject"));
       }
       doc = dc.getNextDocument(doc);
     }
     // Restore conversion
     session.setConvertMIME(true);

  } catch(Exception e) {
     e.printStackTrace();
   }
 }
}

See Also