Agent acting differently when run 'manual' vs. 'scheduled'

Why will this code for Err 4295 hit when I run this agent manually, but not when I schedule the agent?

errorTrap:

If Err=4295 Then 

	Messagebox "Unable to send mail, multiple matches for request "  

	Set doc3 = New NotesDocument(db)

	doc3.Subject = "Agent 2 Error due to names" 			

	doc3.Body ="Unable to send mail for request: " 		

	doc3.SendTo = "John Doe"

	doc3.form = "Memo"

	Call doc3.send(False)

	Set doc3 = Nothing	

	Resume Next		

	

Else	

	'All other error messages		

	....

	Exit Sub

End If



Exit Sub

Subject: Agent acting differently when run ‘manual’ vs. ‘scheduled’

I’m pretty sure the “ambiguous name” thing is a Notes client affair. On the server, you’d probably get a 4160 (send failed) if the router can’t resolve the address.

Subject: RE: Agent acting differently when run ‘manual’ vs. ‘scheduled’

Wouldn’t this fall into the ‘else’ of my ErrorTrap then?

errorTrap:

If Err=4295 Then

Messagebox "Unable to send mail, no match found in the Name & address book for request: "

Set doc3 = New NotesDocument(db)

doc3.Subject = “Fee Schedule Modeling Agent 2 Error due to names”

doc3.Body ="Unable to send mail for request: "

doc3.SendTo = “Tammy Wozniak”

doc3.form = “Memo”

Call doc3.send(False)

Set doc3 = Nothing

Resume Next

Else

'All other error messages

Messagebox "Error: " & Err() & ": " & Error()

Set doc3 = New NotesDocument(db)

doc3.Subject = “Database Agent 2 Error”

doc3.Body ="Check the notes log for error message: " & Err() & ": " & Error()

doc3.SendTo = “Tammy Wozniak”

doc3.form = “Memo”

Call doc3.send(False)

Set doc3 = Nothing

Exit Sub

End If

Exit Sub

Subject: Agent acting differently when run ‘manual’ vs. ‘scheduled’

From what line of code is the error caused? Can you provide the code itself?

What are the restrictions on the agent — the “runtime security level” properties?

Does your ID have access to the database you may be accessing?

Thanks!

Dan

Subject: Other answers: Agent acting differently when run ‘manual’ vs. ‘scheduled’

Restrictions are “1. Do not allow restricted operations.”

I have manager access to this database on a test server.

Appreciate your assistance!

Subject: Code - Agent acting differently when run ‘manual’ vs. ‘scheduled’

When I run the agent manually, I get tossed to the ErrorTrap code on the maildoc.send False line. When I run it as a scheduled agent, I don’t get any error message, but I also don’t receive the ‘good’ email either…

Sub Initialize

Dim session As New NotesSession	

Dim db As notesDatabase

Dim view As NotesView

Dim Doc As NotesDocument	

Dim DocNext As NotesDocument	

Dim MailDoc As NotesDocument	

Dim Doc3 As NotesDocument

Dim item As NotesItem

Dim item2 As notesitem

Dim CheckDate As NotesDateTime 	

Dim Count As Integer

Dim tempToday As New NotesDateTime(Today)		



Set db = session.CurrentDatabase   

Set view = db.GetView("View for Agent 2")     	

Set doc = view.getfirstdocument	



On Error Goto ErrorTrap



While Not (Doc Is Nothing)		

	count = count +1	

	

	Set item = doc.GetFirstItem( "ActEff" )

	Set CheckDate = item.DateTimeValue			

	

	Call CheckDate.AdjustDay(+1)	

	

	difference& = CheckDate.TimeDifference( tempToday ) 

	

	If difference& > 0  Then

		'Msgbox "Not Past Due Yet! "  

		Set doc = view.getnextdocument(doc)

	Else

		'Msgbox "Past Due! "  

		Set maildoc = session.currentdatabase.createdocument

		maildoc.Form = "Memo"			

		maildoc.sendto = doc.RepMarket(0) 				

		

		maildoc.subject = "Needs to be completed "	& doc.LogNumber(0) 			

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

		Call rtitem.Appendtext("Click here to launch the document --> ") 

		Call rtitem.AppendDocLink(doc, db.Title)					

		maildoc.send False

		

		Set docnext = view.getnextdocument(doc)

		

		Set item2 = doc.ReplaceItemValue("StatusCurr","Eff Date Validation")	

		Set item2 = doc.ReplaceItemValue("StatusNumber",7)				

		Call doc.Save( False, False )  

		

		Set doc = docnext			

		

	End If

	

Wend



Messagebox "Fee Schedule Modeling Eff Date Validation Agent Total documents = " & count	



Exit Sub

errorTrap:

If Err=4295 Then 		

	Messagebox "Unable to send mail, no match found in the Name & address book for request: "  

	Set doc3 = New NotesDocument(db)

	doc3.Subject = "Fee Schedule Modeling Agent 2 Error due to names" 		

	doc3.Body ="Unable to send mail for request: " 

	

	doc3.SendTo = "Tammy Wozniak"

	doc3.form = "Memo"

	Call doc3.send(False)

	Set doc3 = Nothing	

	Resume Next		

	

Else	

	'All other error messages		

	Messagebox "Error:  " & Err() & ":  " & Error() 

	Set doc3 = New NotesDocument(db)

	doc3.Subject = "Database Agent 2 Error" 

	doc3.Body ="Check the notes log for error message:  "   & Err() & ": " & Error()  

	doc3.SendTo = "Tammy Wozniak"

	doc3.form = "Memo"

	Call doc3.send(False)

	Set doc3 = Nothing	

	Exit Sub

End If



Exit Sub

End Sub

Subject: Clarification - Code - Agent acting differently when run ‘manual’ vs. ‘scheduled’

When I run the agent manually, I get tossed to the ErrorTrap code on the maildoc.send False line. When I run it as a scheduled agent, I don’t get any error message, but I also DO* (I had previously said ‘do not’) receive the ‘good’ email either…

Subject: Agent acting differently when run ‘manual’ vs. ‘scheduled’

Are the name(s) that cause the failure (when the agent is run manually) in any local address book(s)?

Or does the error occur regardless?

Subject: RE: Agent acting differently when run ‘manual’ vs. ‘scheduled’

Not in any local address book. But I do know there are two similar names in the server address book. That’s why I expect this error. And we can get that cleaned up, but if this error acts differently when running scheduled vs. manually, I worried about what else will act differently?