Domino Code Fragment

Code Name*
FormatDocument method
Date*
04/29/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.135.183.1
Description*
This agent makes a document collection of all the documents (up to 15) in the current database containing the word "arachnid," and makes a newsletter based on the document collection. The agent formats a newsletter document for each document in the collection and sends them to the current user.
Type*
Java
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
import lotus.notes.*;


public class formatdocagent extends AgentBase
{
 public void NotesMain()
 {
   try
   {
     Session s = getSession();
     AgentContext ac = s.getAgentContext();
     Database db = ac.getCurrentDatabase();
     db.updateFTIndex(true);
     DocumentCollection dc = db.FTSearch
     ("arachnid", 15);
     if (dc.getCount()>0)
     {
       Newsletter news = s.createNewsletter(dc);
       Document doc;
       for (int j=0; j<dc.getCount(); j++)
       {
         doc = news.formatDocument(db, j+1);
         doc.appendItemValue("Form", "Memo");
         doc.appendItemValue
         ("Subject", "The Arachnid Report " + (j+1));
         doc.send(false, s.getUserName());
       }
     }
   }
   catch (Exception e)
   {
     e.printStackTrace();
   }
 }
}