Java Agent to Send Mail Hangs

Hi, I have a Java Agent that must send multiple mails to several people, one by one.This mail is with the attach form true.

Using

public void send(boolean attachform, String recipient)

throws NotesException 

But when I run, something is wrong and after severals mails send (20-35) the agent hangs and i nedd to kill my notes applications, because is not responding.

I change te code, but nothing seems helps.

I put false in the send, but neither works.

this is the last try code.

		for (Iterator it=listaDestinos.iterator(); it.hasNext(); ) {

			docMemo = db.createDocument();				

			docMemo.appendItemValue("Form", "formResults");

			docMemo.appendItemValue("Subject", "Results");

			docMemo.replaceItemValue("formResultsEmployee", it.next().toString());

			docMemo.replaceItemValue("SendTo", "Pedro Garcia Haro/CEN/GTI/ABB");

			docMemo.send();

		}

Some ideas?

Subject: Java Agent to Send Mail Hangs

I have the same problem on the second iteration of the send method and have no ideas, how workaroun it/

Subject: RE: Java Agent to Send Mail Hangs

As per Pedro’s reply…

Objects in Java must be recycled when you want to reuse a reference to them. This holds true in Notes / Domino when going through documents in a view or sending multiple emails. Recycling an object means that it is released from memory (The Heap) by the Garbage Collector. If you do not release objects, Java will create a new instance of the object in memory every time the object is initiated until the memory will fill up and the computer can precede no more. Add the following line to your code after the docMemo.Send

docMemo.recycle(); // recycle document object !!

Subject: Java Agent to Send Mail Hangs

Try this:

for (Iterator it=listaDestinos.iterator(); it.hasNext(); ) {

Document docMemo = db.createDocument(); // do not bind to object outside the loop.

docMemo.appendItemValue(“Form”, “formResults”);

docMemo.appendItemValue(“Subject”, “Results”);

docMemo.replaceItemValue(“formResultsEmployee”, it.next().toString());

docMemo.replaceItemValue(“SendTo”, “Pedro Garcia Haro/CEN/GTI/ABB”);

docMemo.send();

docMemo.recycle(); // recycle!!

}

It might have to do with this recycle-thing. You must be carefull with it, when using Java for Domino objects. For example look at recycling section of this article:

regards

Axel

Subject: RE: Java Agent to Send Mail Hangs

Thanks Axel:I try the code with the new changes that suggests, but Notes still hangs when I run the agent.

I run this code.

		for (Iterator it=listaDestinos.iterator(); it.hasNext(); ) {

			Document docMemo = db.createDocument(); // do not bind to object outside the loop. 

			docMemo.appendItemValue("Form", "formResults");

			docMemo.appendItemValue("Subject", "Results");

			docMemo.replaceItemValue("formResultsEmployee", it.next().toString());

			docMemo.send("Pedro Garcia Haro/CEN/GTI/ABB");

			System.out.println(it.next().toString());				

			docMemo.recycle(); // recycle!!

		}

Can be something like a conflicts versions library?

The problem is only when I try to send a mail several times in a cicle, but if I send only one this works fine.

Somebody have a Java agent example that send mails several times?

Thanks in advance