Scheduled Agent Problem - Mail

Hi there,

I have an agent that is written using lotus script. I have it scheduled to RUN daily every hour. When I run the agent manually, it works. The agent’s purpose is to email myself or “a group” if it has a document pending in a particular view. Here is what the log tells me when i RUN it manually on the server. Once I see this message, I do receive the email it is suppose to send.

Started running agent ‘Status Check’ on 01/04/2007 12:10:59 PM

Running on all documents in database: 242 total

Found 1 document(s) that match search criteria

Ran LotusScript code

Done running agent ‘Status Check’ on 01/04/2007 12:11:04 PM

Am i missing something in my code that will not allow the scheduled to run on its own?

maybe like: call agent.run (???)

Any help is greatly appreciated.

Subject: Scheduled Agent Problem - Mail

Post the agent code and also look in the logs at the time you’d expect it to run - you may be getting an error there.

A couple of things it could be though - either the signer of the agent doesn’t have access to run agents on th server or you’re using ui methods in the agent which won’t work in the background but will when you run it manually.

Dan

Subject: RE: Scheduled Agent Problem - Mail

Hi Dan,

Thanks for the info. I looked in the agent log and there is an error (ERROR: Unknown LotusScript Error.):

Started running agent ‘Status Check’ on 01/04/2007 12:02:01 PM

Running on all documents in database: 242 total

Found 1 document(s) that match search criteria

ERROR: Unknown LotusScript Error.

Ran LotusScript code

Done running agent ‘Status Check’ on 01/04/2007 12:02:04 PM

Here’s my code:

Dim session As New notesSession

Dim db As notesdatabase

Dim view As notesview

Dim ventry As notesviewentry

Dim doc As notesDocument

Dim mailDoc As notesDocument

Dim rtitem As notesRichTextItem

Dim richStyle As NotesRichTextStyle

Dim nextDoc As notesDocument



Set s=New notessession

Set db=session.currentdatabase

Set view = db.GetView("(Status)")		

Set mailDoc = New NotesDocument(db)

Set rtitem = mailDoc.CreateRichTextItem("Body")

Set richStyle = session.CreateRichTextStyle



view.AutoUpdate=False



mailDoc.Form = "Memo"

mailDoc.Subject = "ACTION REQUIRED"

mailDoc.From = "Project Delivery Database"

mailDoc.Principal = "Project Delivery Database"

mailDoc.ReplyTo = "TSS-CTC"

	

Call rtitem.AppendText("Reminder: Please take action.")

richStyle.Bold = True

Call rtitem.AppendStyle(richStyle)

richStyle.Bold = False

Call rtitem.AppendStyle(richStyle)

Call rtitem.AppendText(" View 'Outstanding Requests' in database. ")

Call rtitem.AppendDocLink(db, db.Title)

	

Set doc=view.GetFirstDocument



While Not (doc Is Nothing)

	If doc.esstatus(0) = "ACTION REQUIRED" Then

		Call mailDoc.Send(True, "Jerica Santos")

	End If

	Set nextDoc = view.GetNextDocument(doc)

	Set doc = nextDoc

Wend

End Sub

Subject: RE: Scheduled Agent Problem - Mail

at first glance it appears that this line could be causing the error:

Set s=New notessession

try adding an error hadling routine to your code so it prints the error to the cosole and captures the line number where the error is occurring. Something like this:

On Error Goto errHandler

your code here

errHandler:

Print Err & " at line number " & Erl & " - " & Error

Resume next

Subject: RE: Scheduled Agent Problem - Mail

Hi,

Unfortunately I dont have access to the server console log / agent manager.

Any other suggestions?

Subject: RE: Scheduled Agent Problem - Mail

I think the agent is working, But I do have a question. If i am the signer or creator of the agent, Would I receive a copy of the emails that are suppose to be sent out? I think thats why I didnt think the scheduled agent wasnt working … as I wasnt receiving the emails that the agent is suppose to be doing …

Subject: RE: Scheduled Agent Problem - Mail

The answer to that is no - only the script determines who the mails go to