Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2006
    Posts
    44

    Unanswered: Batch File problem

    Hi... not sure where to put this question at.. so i think i put it here since i'm doing asp project...

    May i know how to code a Batch file?
    I'm doing a project on ASP and currently i need a batch file to help me auto send an email at a certain time and auto update my database details..

    I have no ideals how to start at all.. This my 1st time doing.. Hope some1 could help mi..

    Thanx

  2. #2
    Join Date
    Nov 2005
    Location
    Honolulu HI
    Posts
    119
    a batch file is an old DOS type of program that hardly anyone uses any more.

    what your looking for is an ASP Script.

    Questions :
    do you have a web service already ? (a hosting account)
    does your hosting account have ASP Enabled ? some hosting accounts are only Linux and PHP. assuming that is a YES... then something like this SHOULD send your email out. provided that the hosting account has CDONTS active.

    this page is designed to be INCLUDED into another after you have set the required variables and done validation.


    Code:
    <%
    ' ==============================================================
    '   Created By : GetMySiteOnline.Com
    '   Created On : Sunday, April 24th, 2005
    ' Routine Name : SendEmail.asp
    '  Description : Main Page to send Emails
    '		 Used to store info the system sends out or
    '		 Forms the users fills out and submits
    '
    ' Modification History :
    ' Modified On	Reason
    '
    ' ==============================================================
    %>
    <!--#include file="DatabaseConnectionInfo.asp"-->
    <%
    ' _________________________________________________________________________________________
    	if intUserRecordID ="" then intUserRecordID ="0"
    	if strFullName ="" then strFullName ="{No Name Given}"
    	if strUserName ="" then strUserName ="{No UserName Given}"
    
    	strNow =Now()
    	if strCategory ="" then strCategory ="{no category}"
    	if strSubject ="" then strSubject ="{no subject}"
    ' __________________________________________________________________________
    	' Insert the Email contents into the database.
    		SQL="INSERT INTO EmailTable (ReadStatus, OutBound, UserRecordID, UserName, Name, EmailAddress, DateTime, Category, Subject, Body) VALUES ('0', '1', '" & intUserRecordID & "', '" & strUserName & "', '" & strFullName & "', '" & strEmailAddress & "', '" & strNow & "', '" & strCategory & "', '" & strSubject & "', '" & strBody & "')"
    		TheDatabase.Execute(SQL)
    ' __________________________________________________________________________
    '	Setup the email Message
    		strMsgHeader = "Greetings From OurWebSite.com  !"
    		strMsgHeader = strMsgHeader & vbcrlf & vbcrlf
    		strMsgHeader = strMsgHeader & "THANK YOU for taking the time to write to us !"
    		strMsgHeader = strMsgHeader & vbcrlf
    		strMsgHeader = strMsgHeader & "This is an Automated Notification that we have received your Message. There is no need to respond to this email at this time. We will review your message and if warranted, respond appropriately."
    		strMsgHeader = strMsgHeader & vbcrlf
    		strMsgHeader = strMsgHeader & "Your Original Message Is Below."
    		strMsgHeader = strMsgHeader & vbcrlf
    		strMsgHeader = strMsgHeader & "______________________________________________________________" & vbcrlf
    		strMsgHeader = strMsgHeader & "FROM     : " & strFullName & vbcrlf
    		strMsgHeader = strMsgHeader & "Email    : " & strEmailAddress & vbcrlf
    		strMsgHeader = strMsgHeader & "To       : yourEmail@yourDomain.Com" & vbcrlf
    		strMsgHeader = strMsgHeader & "Sent     : " & strNow & vbcrlf
    		strMsgHeader = strMsgHeader & "Category : " & strCategory & vbcrlf
    		strMsgHeader = strMsgHeader & "Subject  : " & strSubject & vbcrlf
    		strMsgHeader = strMsgHeader & vbcrlf & vbcrlf
    
    
    		strMsgFooter = vbcrlf & "______________________________________________________________" 
    		strMessage = strMsgHeader & strBody & strMsgFooter
    
    ' __________________________________________________________________________
    '	Send the Email.
    		'Create the CDONTS Object
    		set objMail = Server.CreateObject("CDONTS.NewMail")
    
    		'Set up the mail parameters
    		objMail.To = strEmailAddress 
    		objMail.From = "yourEmail@yourDomain.Com"
    		objMail.Bcc = "AnotherEmail@yourDomain.Com"
    	'	objMail.Value("Reply-To") = ""
    		objMail.Subject = strSubject 
    		objMail.Body = strMessage 
    
    		'Send the message and release the Object
    		objMail.Send
    		set objMail = nothing
    ' __________________________________________________________________________
    %>
    .
    .
    http://www.HawaiianHope.org
    Providing Technology services to non profit orgs, Homeless Shelters, Food Pantries, Clean And Sober Houses and more.
    To date we have given away over 900 free computers !
    __________________________
    caeli enarrant gloriam Dei !

  3. #3
    Join Date
    Jan 2006
    Posts
    44
    hi, thanks for your reply..

    I already have the email format like yours in my asp file..

    but how can i send an email out automatically once every few days without me clicking any buttons?

  4. #4
    Join Date
    Nov 2005
    Location
    Honolulu HI
    Posts
    119
    you have any page counters, visitor counters ?

    one way to do it is store a "date to send" in the database... and each time a new person visits your site... if you do anything with a visitor number or anything. in the first page when you send your info to the database you can have it check that date.

    if it is the correct date/time, then send it and reset the date to send it to the next (future) date to send.

    if your using MS-SQL server, you could possibly use a trigger or stored procedure....
    .
    .
    http://www.HawaiianHope.org
    Providing Technology services to non profit orgs, Homeless Shelters, Food Pantries, Clean And Sober Houses and more.
    To date we have given away over 900 free computers !
    __________________________
    caeli enarrant gloriam Dei !

  5. #5
    Join Date
    Jan 2006
    Posts
    44
    erm.. but i don want to send it when some1 visits the site.
    I want it to check everyday 12am to see if there's any mails to send.

  6. #6
    Join Date
    Nov 2002
    Location
    Houston, Texas
    Posts
    85
    I had a similar problem a few years ago and someone else solved it, so I'm not 100% sure of the solution. However, if memory serves me right, you might start by searching for info on "Triggers" and "Cron Jobs." I believe the solution was to write a Windows script (a filename.ws) and register it on your server so that it will call the job at a specific time.

    Wish I could have been of more help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •