Schedule ASP Script

i want to create a script in ASP which will run automatically at a particular time, daily and check the Delivery date in access database. Before 3 days of  Delivery date  i want to send E-mail Automatically. Email information, Receiptent name are comming from data base.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

apurvkansalAuthor Commented:
i want to it urgent.
Thandava VallepalliCommented:
create a  .vba file....  make it schedule using  windows scheduler....

same asp code you can copy and paste it in  .vba file....

justinbilligConnect With a Mentor Commented:
or you could schedule a VB exe, either way works
MinakiSerindeConnect With a Mentor Commented:
' Database connection string. Could be an ODBC Data Source Name called yourdns or whatever, or you could write it manually
Const DB_CONNECTION_STRING = "dsn=yourdsn;"

' SQL SELECT statement that pulls whichever record you want to go by from the DB

' Mail Details
Const MAIL_FROM = ""
Const MAIL_SUBJECT = "Your Message Subject"
Const MAIL_BODY = "Your Message Body"

Set objRecordset = CreateObject("ADODB.Recordset")
objRecordset.ActiveConnection = DB_CONNECTION_STRING
objRecordset.Source = SQL_SELECT_STATEMENT
objRecordset.CursorType = 0
objRecordset.CursorLocation = 2
objRecordset.LockType = 1

' Change this line according to what the field containing your recipient is
strMailTo = objRecordset.Fields.Item("EMail").Value

' Change this according to the Date field in your DB
myDate = objRecordset.Fields.Item("Date").Value

Set objRecordset = Nothing

If DateDiff("d", Now, myDate) < 3 then

      Set objCDOSYSMail = CreateObject("CDO.Message")
      Set objCDOSYSCon = CreateObject ("CDO.Configuration")

      objCDOSYSCon.Fields("") = MAIL_SERVER_ADDRESS
      objCDOSYSCon.Fields("") = 25
      objCDOSYSCon.Fields("") = 2
      objCDOSYSCon.Fields("") = 60
      Set objCDOSYSMail.Configuration = objCDOSYSCon
      objCDOSYSMail.From = MAIL_FROM
      objCDOSYSMail.To = strMailTo
      objCDOSYSMail.Subject = MAIL_SUBJECT
      objCDOSYSMail.HTMLBody = MAIL_BODY
      Set objCDOSYSMail = Nothing
      Set objCDOSYSCon = Nothing
End If

Copy the above code and paste into Notepad. Save it with a .vbs extension, and change all the bits that are commented to be changed, depending on your setup.

You can then use the AT command, windows sheduler, or any third party scheduling program to run the script on the specified day/time. It's a lot more robust than runninng it from a scheduled ASP page.

Note: You will need Windows Scripting Host installed. It's free from Microsoft and you'll probably have it already.

Note2: I havn't fully tested the code, it might need some messing.
All Courses

From novice to tech pro — start learning today.