How do I test this? [Archive] - SpeedGuide.net Broadband Community

View Full Version : How do I test this?


chumee
09-07-02, 02:14 PM
Hi ppl, its me again! This is the code i came up with for my program where I want to automatically send an email to users in a database on a given date:

<html>
<head><title>Who's birthday is it today?</title></head>
<body>
<%
var1=now()
var2=DatePart("m", var1) & "/"& DatePart("d", var1)
'Date in m/d format

Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "FILEDSN=C:\Program Files\Common Files\ODBC\Data Sources\birthday.dsn"
Set Rs=MyConn.Execute("SELECT * FROM birthdayTable")

while not Rs.EOF
IF var2=Rs("Birthday") THEN
'Dates in the table are also m/d format
Response.write("<br>")
name=Rs("Name")
Response.write("&nbsp;&nbsp;"&name)
mail=Rs("Email")
Response.write("&nbsp;&nbsp;"&mail)
Response.write("&nbsp;&nbsp;"&Rs("Birthday"))

'Prints the name, email, birthday of the selected individual

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = "Me"
Mailer.FromAddress= someone@here.com
Mailer.RemoteHost = "mail.emirates.net.ae"
Mailer.AddRecipient name, mail
Mailer.Subject = "Wishing you a happy birthday!"
Mailer.BodyText = "Happy birthday to you!!!"

If Mailer.SendMail Then
Response.Write "Mail send success!"
Else
Response.Write "Mail send failure. Error was " & Mailer.Response
End if

END IF
Rs.moveNext
wend
Rs.close
MyConn.close
%>
</body>
</html>

But how do I test if it works from my local machine? Should I install ASPMailer? And I'm not sure of the remote host name I should use.

Does anyone have any idea what I should do?
chumee

FunK
09-17-02, 05:21 PM
I would install the mailer or look into the default mailer for Winderz and write the code to match it....

I take it that you are getting some kind of error? Post the error that you get when you try to run the script and have it mail out the message.

Either that, or just load it on your remote server and see if it works from there. Use your own e-mail address in place of one in the database (remove database code for testing) and see if it send you the message. If so, then include the database portion.

You could also include the year in the date. That way you could subtract the year the person was born from the current year and send Happy Slappy 21st birthday!!!!

Then again, that would not be fun.......

FunK