Let's say there is an ExpiryDatefield in the table with events.
To send email if event was expired create new asp file (dailysendmail.asp for example), place this file under generated output directory.
Here is a sample script (for MS Access database):
<!--#include file="include/dbcommon.asp"-->
<%
dalTableName = dal.Table("TableName")
set rstmp = dalTableName.Query("DateDiff('d', Now(), ExpiryDate)>0","")
while not rstmp.eof
'send email for each record
msg = "This event was expired" & vbcrlf
msg = msg & "FieldName1: " & rstmp("FieldName1") & vbcrlf
msg = msg & "FieldName2: " & rstmp("FieldName2") & vbcrlf
set params = CreateObject("Scripting.Dictionary")
params("to")=rstmp("EmailField")
'EmailField is your actual field name
params("subject")="Expired"
params("body")= msg
runner_mail(params)
rstmp.movenext
wend
'FieldName1, FieldName2 and ExpiryDate are your actual field names, TableName is your actual table name
rstmp.close
set rstmp=nothing
%>
To apply this sample for MSSQL database edit SQL query in the following way:
set rstmp = dalTableName.Query("DATEDIFF(day, GETDATE(), ExpiryDate)>0","")
and for MySQL:
set rstmp = dalTableName.Query("DateDiff(now(),ExpiryDate)>0","")
Then use cron to run this script on timely fashion i.e. once a day.
You can use SetCronJobservice to run this script if cron is disabled on your web server:
http://www.setcronjob.com/'>http://www.setcronjob.com/
Here is a step-by-step instruction on how to set up cron job usign SetCronJob:
- register on the http://www.setcronjob.com/'>http://www.setcronjob.com/
- activate your account and login,
- go to Control Panel and click on the 'Create new cron job' link,
- fill 'URL to call' with correct URL to your script. For example your generated files are under 'asprunner' directory:
http://yourhosting.com/asprunner
So correct URL will be:
http://yourhosting.com/asprunner/dailysendmail.asp
- Save.