If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Batch File problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-08-06, 23:25
Cuttie0506 Cuttie0506 is offline
Registered User
 
Join Date: Jan 2006
Posts: 44
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
Reply With Quote
  #2 (permalink)  
Old 02-09-06, 01:19
kropes2001 kropes2001 is offline
Registered User
 
Join Date: Nov 2005
Location: Honolulu HI
Posts: 118
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.GetMySiteOnline.com - Can you help me Get My Site Online ? (Yes. That is EXACTLY what we do.)

http://www.GetMySiteOnline.com/FightingSpam/
__________________________
caeli enarrant gloriam Dei !
Reply With Quote
  #3 (permalink)  
Old 02-09-06, 02:09
Cuttie0506 Cuttie0506 is offline
Registered User
 
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?
Reply With Quote
  #4 (permalink)  
Old 02-10-06, 03:09
kropes2001 kropes2001 is offline
Registered User
 
Join Date: Nov 2005
Location: Honolulu HI
Posts: 118
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.GetMySiteOnline.com - Can you help me Get My Site Online ? (Yes. That is EXACTLY what we do.)

http://www.GetMySiteOnline.com/FightingSpam/
__________________________
caeli enarrant gloriam Dei !
Reply With Quote
  #5 (permalink)  
Old 02-12-06, 20:13
Cuttie0506 Cuttie0506 is offline
Registered User
 
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.
Reply With Quote
  #6 (permalink)  
Old 02-24-06, 15:30
buzzter66 buzzter66 is offline
Registered User
 
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!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On