import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
// 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) {
if (mime.getContentType().equals("text") &&
mime.getContentSubType().equals("plain")) {
Stream stream = session.createStream();
String pathname = "c:¥¥lotus¥¥notes¥¥data¥¥temp.txt";
if (stream.open(pathname, "us-ascii")) {
mime.getEntityAsText(stream);
stream.close();
break;
}
else System.out.println
("Can't open c:¥¥lotus¥¥notes¥¥data¥¥temp.txt");
}
else System.out.println("Not plain text");
}
else
{
System.out.println
("Not MIME - " + doc.getItemValueString("Subject"));
}
doc = dc.getNextDocument(doc);
}
// Restore conversion
session.setConvertMIME(true);
} catch(Exception e) {
e.printStackTrace();
}
}
}
import lotus.domino.*;
import java.util.Vector;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
// 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) {
if (mime.getContentType().equals("text") &&
mime.getContentSubType().equals("plain")) {
Stream stream = session.createStream();
String pathname = "c:¥¥lotus¥¥notes¥¥data¥¥temp.txt";
if (stream.open(pathname, "us-ascii")) {
Vector filters = new Vector();
filters.addElement("From");
filters.addElement("Subject");
mime.getEntityAsText(stream, filters, true);
}
else System.out.println
("Can't open c:¥¥lotus¥¥notes¥¥data¥¥temp.txt");
}
else System.out.println("Not plain text");
}
else
{
System.out.println
("Not MIME - " + doc.getItemValueString("Subject"));
}
doc = dc.getNextDocument(doc);
}
} catch(Exception e) {
e.printStackTrace();
}
}
}