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(" "&name)
mail=Rs("Email")
Response.write(" "&mail)
Response.write(" "&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
<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(" "&name)
mail=Rs("Email")
Response.write(" "&mail)
Response.write(" "&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