Scheduler Agent

 

This code sniped displays an Agent. The agent is of type Planner. This agent every 20 minutes wakes up an checks for what has to do. Its job is to prepare an HTML mail to John, about the activities of the users in the system. The initial HTML file, that contains the AutoScript, is the HISTORY.HTM. The HTML file that is produced is the _HISTORY.HTM (after the call to html_processfile). The agent sends this mail only at 11 o'clock every day.

 

{...................................................AGENT INFO..............................................}

 

start_agent_info

  AgentName = "Activity_Mailer"

  AgentDescr = "Activity information to the John"

  AgentLanguage = ""

  __timer_interval = 1200      { in seconds }

  __is_registered = 0

  __delete_on_termination = 0

end_agent_info

 

{.................................ACTION CODE................................................}

 

start_action

 

  {............Every day at 11 we send mail about the users activities to John. The mail is in HTML form}

 

  when ( _TraversingHour = 11 ) and ((_CurrentDate_Num > fired_date) or (fired_date = 0)) do

 

       email = "This email address is being protected from spambots. You need JavaScript enabled to view it."

 

       call html_processfile("HISTORY.htm")

       body = html_gettext("_HISTORY.htm")

       mail = smtp_create()

       call smtp_setbody(mail, body)

       call smtp_setcontent(mail, "text/html")

       call smtp_send(mail, "my_smpt" ,  "Activities",  "John",  email )               

 

  endwhen

 

end_action

 

 

See also HTML processing.