After new mail has arrived agent in mailbox

I have a “After new mail has arrived” agent in mailbox.

The code is more or less the following:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Set db = session.CurrentDatabase

Set collection = db.UnprocessedDocuments

Set doc = collection.GetFirstDocument

If Not doc Is Nothing Then

’ do some things …

End If

The problem is that the agent runs BUT no doc is return from the collection. I have checked and the collection.Count return 0 (cero) documents.

I am wondering if the agent runs is because there is, at least, one document BUT why I can’t get it ?

Thanks

Subject: Revised Answer

Hello, Juan. You are correct using the NotesDocumentCollection UnprocessedDocuments property to get a handle to the new email because your agent is an After new mail has arrived agent. How did you verify that zero documents in the collection. Did you use a print statement to send the count to the Notes log? I have another question for you. Is there any selection criteria specified in the agent?

Subject: I have tried but …

did not work. From which I have read the document context works with “before new mail has arrived” while db.unproceseddocuments works with “after new mail has arrived”.

Am I wrong ?

Subject: Another question

Juan, please answer my questions in my revised response. Also, I wanted to ask, do you have any other mail agents running in this database?

Subject: Your answers and more comments

I have verified the cero documents by cheking the collection.Count property oof the notesdocumentcollection objetc.-

I have used a print statemente to check as described aboved. On the other hand, I think you can not specify any selection criterian on this kind of agents.-

I don’t have any other agents running on mailbox.-

I think the problem is that when a tried to set the document, the document had left the mailbox and gone to the user’s mail database.-

I’m wondering if there is any posibility to cause a delay in the mailbox just to get a chance to set the document in my LS agent.-

Thanks a lot