I have a java agent that sends mails with attachment in a loop. But it hangs when second mail sending. I think it is a bug. Is there anyone faced this problem?
The code is here:
import java.io.File;
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
System.out.println("Sendmail started ######");
for(int i = 0 ; i < 5 ;i++){
Document memo = agentContext.getCurrentDatabase().createDocument();
System.out.println("#1");
RichTextItem body = memo.createRichTextItem("Body");
System.out.println("#2");
body.embedObject(EmbeddedObject.EMBED_ATTACHMENT, null, "c:\\Temp\\Teklif"+i+".pdf", "Teklif");
System.out.println("#3");
memo.send("Mehmet Sunkur"); //!!!!! Hangs here when execution(i=1) comes second time
System.out.println("#4");
memo.removePermanently(true);
System.out.println("#5");
body.recycle();
System.out.println("#6");
memo.recycle();
System.out.println("#7");
System.gc();
System.out.println("#8");
File f = new File("c:\\Temp\\Teklif"+i+".pdf");
System.out.println("#9");
f.delete();
System.out.println("#10");
System.gc();
System.out.println("Sendmail ended #################");
}
} catch(Exception e) {
e.printStackTrace();
}
}
}