Solved

Schedule ASP Script

Posted on 2004-10-07
8
326 Views
Last Modified: 2012-06-22
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.
0
Comment
Question by:apurvkansal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 

Author Comment

by:apurvkansal
ID: 12256356
i want to it urgent.
0
 
LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 12256548
create a  .vba file....  make it schedule using  windows scheduler....

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

itsvtk
0
 
LVL 14

Accepted Solution

by:
Thandava Vallepalli earned 168 total points
ID: 12256561
0
 
LVL 15

Assisted Solution

by:justinbillig
justinbillig earned 166 total points
ID: 12257689
or you could schedule a VB exe, either way works
0
 

Assisted Solution

by:MinakiSerinde
MinakiSerinde earned 166 total points
ID: 12287879
' 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
Const SQL_SELECT_STATEMENT = "SELECT * FROM YourTable"

' Mail Details
Const MAIL_SERVER_ADDRESS = "127.0.0.1"
Const MAIL_FROM = "you@yourdomain.com"
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
objRecordset.Open()

' 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("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MAIL_SERVER_ADDRESS
      objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
      objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
      objCDOSYSCon.Fields.Update
      
      Set objCDOSYSMail.Configuration = objCDOSYSCon
      objCDOSYSMail.From = MAIL_FROM
      objCDOSYSMail.To = strMailTo
      objCDOSYSMail.Subject = MAIL_SUBJECT
      objCDOSYSMail.HTMLBody = MAIL_BODY
      objCDOSYSMail.Send
      
      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.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question