Calling Agent from Database Script

Hi,I need to run an agent within Database Script’s postopen event. Below is my code in the postopen event:


Dim s As New NotesSession

Dim Agent As NotesAgent

Dim db As NotesDatabase

Set db=s.Currentdatabase

Set Agent = db.GetAgent( “AgentName” )

Dim datev As New NotesDateTime(agent.LastRun)

Dim datex As New NotesDateTime(Now())

Dim date0, date7, datetoday As String

date0 = datev.DateOnly

'day the agent ran

Call datev.AdjustDay (+7)

date7 = datev.DateOnly

'7 days after the agent run

datetoday = datex.DateOnly 'today

If date7 = datetoday Then

agent.Run	

End If


The agent log shows that the agent did run, but, the agent doesn’t trigger the alert (messagebox) that I have in the code. Is there anything that I did wrong in the agent.run statement? Is my approach possible at all?

What I am doing is to alert users with certain mail file size weekly when they open their mail files.

Any suggestion is appreciated. Thanks for your help in advance.

Below is my agent code:


Dim db As NotesDatabase

Dim session As New NotesSession

Dim size As Double

Dim sizemb As Double

Set db = session.CurrentDatabase

size = db.size

If size >200000000 Then

sizemb = size/1024/1024

Msgbox "Your mail file size is: “& sizemb & " MB” , MB_OK , “Warning”

End If


Subject: Calling Agent from Database Script

As you are calling a back end agent, the Messagebox will not display. It should, however appear as a message in the server log.

There is no real reason to call this as an agent. Just run it as part of the database script.

Subject: RE: Calling Agent from Database Script

Thanks for your response. The reason I want to run an agent is because I need to get a handle of the “last run” date since we need to run this weekly, and I can’t find a way to determine the “day” (For example, Ideally, I want to run the agent on Monday).