JAVA/CORBA CLASSES
Examples: Preamble property
1. This agent gets the preamble for a multipart MIME item.
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();
if (mime != null) {
System.out.println(doc.getItemValueString("Subject"));
if (mime.getContentType().equals("multipart")) {
if (mime.getPreamble().trim().equals("")) {
System.out.println("No preamble");
}
else {
System.out.println(mime.getPreamble());
}
}
else {
System.out.println("Not multipart");
}
}
else {
System.out.println("Not MIME - " +
doc.getItemValueString("Subject"));
}
doc = dc.getNextDocument(doc);
}
// Restore conversion
session.setConvertMIME(true);
} catch(Exception e) {
e.printStackTrace();
}
}
}
2. This agent sets a preamble in the parent entity of a multipart MIME item.
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");
body.setPreamble("Preamble to multipart message.");
header = body.createHeader("Subject");
header.setHeaderVal("MIME message");
header = body.createHeader("To");
header.setHeaderVal("Robert Perron");
// 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
Preamble property
Glossary
Feedback on
Help
or
Product Usability
?
Help on Help
All Help Contents
Glossary