JAVA/CORBA CLASSES


Examples: createHeader method
This agent creates Content-Type, Subject, and To headers for the parent entity in a multipart MIME entity. SetContentFromText generates headers for the child entities through parameters 2 (Content-Type) and 3 (Content-Transfer-Encoding).

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);
     Database db = agentContext.getCurrentDatabase();
     Document doc = db.createDocument();
     // Create parent entity
     doc.replaceItemValue("Form", "Memo");
     MIMEEntity body = doc.createMIMEEntity();
     MIMEHeader header = body.createHeader("Content-Type");
     header.setHeaderVal("multipart/mixed");
     header = body.createHeader("Subject");
     header.setHeaderVal("MIME message");
     header = body.createHeader("To");
     header.setHeaderVal("Roberta Person");
     // Create first child entity
     MIMEEntity child = body.createChildEntity();
     stream.writeText("Text of message for child 1.\n");
     child.setContentFromText(stream, "text/plain", MIMEEntity.ENC_NONE);
     stream.truncate();
     // Create second child entity
     child = body.createChildEntity();
     stream.writeText("Text of message for child 2.");
     child.setContentFromText(stream, "text/plain", MIMEEntity.ENC_NONE);
     doc.send(false);
     // Restore conversion
     session.setConvertMIME(true);
   
   } catch(Exception e) {
     e.printStackTrace();
   }
 }
}

See Also