On Error question

Hello everybody:

I have a problem with “Error Handling”. If I run this agent manually it records an error in a Agent Log. When it scheduled it doesn’t record any errors.

Error is: "Unable to send mail, no match found in Name & Address Book(s).

Thank you for your help and have a greate weekend.

Sub Initialize

On Error Goto ErrorMyAgent



Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim item As NotesItem



Dim sendto As String



    Dim CurrentLog As NotesLog

Dim AgentLog As New NotesLog("Agent Log")

Set CurrentLog = New NotesLog( "Agent Log" )

	

Set db = session.CurrentDatabase

Set view = db.GetView( "View Name" )

Set doc = view.GetFirstDocument



While Not ( doc Is Nothing )

	GetName = doc.GetItemValue( "OSName" )

	Set maildoc = New NotesDocument(db)

	maildoc.Form = "memo"

	maildoc.SendTo = GetName(0)

	

	Set rtitem = New NotesRichTextItem( maildoc, "Body" )

	Call rtitem.AppendText("Some text goes here")

	Call rtitem.AddNewLine(2)

	Call rtitem.AppendText("Regards")

	

	maildoc.subject = "Here is the subject line."

	Set mailitem = New NotesItem(maildoc, "_ViewIcon", 23 )

	Call maildoc.send(False, sendto)

	Set doc = view.GetNextDocument( doc )

Wend

Exit Sub

ErrorMyAgent:

Call currentLog.OpenNotesLog( db.Server, “agentlog.nsf” )

Call currentLog.LogAction(“Error” & Str(Err) & ": " & Error$ & " Line: " & Erl())

Call currentLog.Close

Resume Next 	

Exit  Sub

End Sub

-vadim

Subject: On Error question

When its scheduled on whose rights does the agent run ? Probably the agent signer doesnt have rights to access “Agentlog” database. Just a thought !

Raj