JAVA/CORBA CLASSES
Examples: Newsletter class
1. This agent performs a full-text search on the current database and creates a newsletter. The agent formats a newsletter message containing a link to each matching document and sends it to the current user.
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext =
session.getAgentContext();
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
db.updateFTIndex(true);
DocumentCollection dc = db.FTSearch("arachnid", 15);
if (dc.getCount() > 0) {
Newsletter news = session.createNewsletter(dc);
news.setSubjectItemName("Subject");
news.setDoSubject(true);
Document doc = news.formatMsgWithDoclinks(db);
doc.appendItemValue("Form", "Memo");
doc.appendItemValue("Subject", "The Arachnid
Report");
doc.send(false, session.getUserName()); }
} catch(Exception e) {
e.printStackTrace();
}
}
}
2. This agent performs a full-text search on the current database and creates a newsletter. The agent formats a newsletter document for each matching document and saves it in the database Reports.nsf.
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext =
session.getAgentContext();
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
db.updateFTIndex(true);
DocumentCollection dc = db.FTSearch("arachnid", 15);
if (dc.getCount() > 0) {
Newsletter news = session.createNewsletter(dc);
Document doc;
Database reports = session.getDatabase(null,
"reports");
for (int j=0; j<dc.getCount(); j++) {
doc = news.formatDocument(reports, j+1);
doc.appendItemValue("Form", "Main Topic");
doc.appendItemValue("Subject", "The Arachnid
Report " + (j+1));
doc.appendItemValue("Categories", "Reports");
doc.appendItemValue("From",
session.getCommonUserName());
doc.save(true, true); }}
} catch(Exception e) {
e.printStackTrace();
}
}
}
See Also
Newsletter class
Glossary
Feedback on
Help
or
Product Usability
?
Help on Help
All Help Contents
Glossary