"After mail arrives" agent just will not work!

I know Julie has addressed this earlier, but I looked over all of the posts, and it is not clear to me what could be wrong.

I have an agent on a mail file that I want to forward to a specific group address from our NAB. I set it to run “after mail arrives”.

It never runs. Or at least that is what the agent log says. And the results I want do not occur.

Here is the code. Can anybody tell me what I am doing wrong?

I think the problem is my understanding the relationship between what the agent is supposed to work on (newly arrived email) and the Unprocessed Documents property of NotesDatabase. When I run it manually, my documentcollection returns 0 documents, but this is right after a new email has arrived.

===============================

Dim s As New NotesSession

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Dim memo As NotesDocument

Dim rti As NotesRichTextItem

Dim dow As Integer, ok As Integer	

Dim docbody As Variant



Set db = s.CurrentDatabase

Set dc = db.UnprocessedDocuments '<===IS THIS MY PROBLEM???



If dc.Count = 0 Then

	Msgbox "No documents in the Unprocessed Document Collection"

End If



Set doc = dc.GetFirstDocument

dow = Weekday(Now())

ok = 0



'make sure this is after hours or on a weekend

If Hour(Now()) > 5 And Minute(Now()) > 29 Then 'is it after 5:30

	ok = 1

End If



If dow = 1 Or dow = 7 Then

	ok = 0

End If



ok = 1 'enable this line if you want the agent to run 24X7 every day



If ok = 1 Then

	Do While Not (doc Is Nothing)

		Set memo = db.CreateDocument

		memo.form = "Memo"

		memo.SendTo = "OnCallEmail"

		memo.Subject = "New mail received in Help Desk mail"

		Set rti = New NotesRichTextItem(memo,"Body")	

		Set docbody = doc.GetFirstItem("Body")

		Call rti.AppendText("The following email was received in the Help Desk mail file.")

		Call rti.AddNewline(2)	

		Call rti.AppendRTItem(docbody)

		Call memo.Send(False)

		Set doc = dc.GetNextDocument(doc)

	Loop			

End If

Subject: “After mail arrives” agent just will not work!!

The mos tcommon mistake has to be with expecting the agent to run on a wrong server. Did you try running the ‘test’ diagnostic? It should tell you what the issue is.