Hi,I have an agent (that should forward a mail) and that really is supposed to run after new mail arrives. It however keeps running and sending mails even when they are not new. You can imagine how annoying it is. Does anyone kow how to deal with this/why it is happening.
Subject: Agent Keeps running & running…! Any ideas why pls?
So the trigger is when new mail arrives, but how are you selecting the data to process? If you don’t do anything to stamp the data touched as being processed, then your code will just keep touching the same data.
Thanks for your response Ben. I don’t understand the question how am Iselect the data to process. The data to process are new mails that arrive. Should that not be sufficient enough for the agent to understand what should be done?
The agent trigger “After new mail arrives” is precisely that: a trigger. Your code still needs to say what you want the Notes server to do. I assume you mean that for each new mail that arrives, your code should do something to that mail. Fine. But it also needs to set the document as having been processed once the work’s done so that it doesn’t get processed again. If you’re using Lotusscript, then read the Domino Designer help on the NotesDatabase property “UnprocessedDocuments” as this can tell you more. For example:
Using UpdateProcessedDoc
For agents that run on new and modified documents, newly received mail documents, pasted documents, or newly modified documents, you must use the UpdateProcessedDoc method in NotesSession to mark each document as “processed,” which ensures that a document gets processed by the agent only once (unless it’s modified, mailed, or pasted again). If you do not call this method for each document, the agent processes the same documents the next time it runs.
So, if your code does something like this:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
While Not(doc Is Nothing)
...
… before you move on to the next document at the end of the loop, you need to do something like this: