JAVA/CORBA CLASSES

Examples: setContentFromBytes method
This agent creates a document in MIME format. The MIME content is one .gif file.

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();
     doc.replaceItemValue("Form", "Memo");
     MIMEEntity body = doc.createMIMEEntity();
     header = body.createHeader("Subject");
     header.setHeaderVal("MIME image from GIF file");
     if (stream.open("c:\\lotus\\notes\\data\\folder.gif", "binary")) {
       if (stream.getBytes() != 0) {
         body.setContentFromBytes(stream, "image/gif",
         MIMEEntity.ENC_IDENTITY_BINARY);
       }
       else System.out.println
         ("c:\\lotus\\notes\\data\\folder.gif has no content");
     }
     else System.out.println("Error opening
       c:\\lotus\\notes\\data\\folder.gif");
     stream.close();
     doc.save(true, true);
     // Restore conversion
     session.setConvertMIME(true);
   
   } catch(Exception e) {
     e.printStackTrace();
   }
 }
}

See Also