anessa05
02-22-2006, 09:32 PM
Hello,
I'm trying to create a simple form that someone who has forgotten their password can enter their email address and, if the email matches the db, email them their password. I cannot find an example for doing this with JMail. I'm using ASP and a MS SQL database. The 'employers' db has the fields 'email' and 'pw'. I'm a newbie, so an example would be most helpful. Any assistance would be very much appreciated. Below is my trainwreck of code...
<!-- FORM PAGE -->
<form method="POST" action="sendpassword.asp">
E-mail Address:<input type="text" name="email" size="30">
<p><input type="submit" value="Send it"></p>
</form>
<!-- END FORM PAGE -->
<!-- FORM ACTION PAGE -->
<%@ LANGUAGE="VBSCRIPT" %>
<!-- DATABASE CONNECTION INCLUDE -->
<!-- #include file="db.inc" -->
<html>
<%
If (Request.Form("email") = "") Then
"SELECT * FROM Employers WHERE email = '" & email & "'"
%>
<head>
<title>Send Password</title>
</head>
<body>
<%
'checks if email address exists in the database before sending a message.
If objrs.EOF then
%>
<table border="0" cellPadding="0" cellSpacing="1" width="540">
<tr>
<td bgcolor="#FF0000"><font color="#FFFFFF"><b>Invalid Email Address</b></font></td>
</tr>
</table>
<p><span>We could not find</span><span> <%=email%></span>
<span> in our database.</span></p>
<% Else %>
<%
'sets variables
email = request.form("email")
'chooses email/username and password from database that correspond to submitted email address.
pass = objrs.Fields("pw")
Set JMail = Server.CreateObject("JMail.SMTPMail")
JMail.ServerAddress = "SERVER ADDRESS REMOVED FOR FORUM POST"
JMail.Sender = "SENDER ADDRESS REMOVED FOR FORUM POST"
JMail.Subject = "Your Password"
JMail.AddRecipient = email
JMail.Body = "Your user name and password are below as requested:" & vbCrLf
JMail.Body = JMail.Body & "Per your request your account login information is: " & vbCrlf & vbCrlf _
& "Password=" & pw & vbCrlf
JMail.Body = JMail.Body & "You may now use these to log on"
JMail.Priority = 3
JMail.Execute
%>
<p>We just sent your login information to <%=email%>.<br>
You should receive it shortly.</p>
<%
' Close Data Access Objects and free connection variables
objDC.Close
Set objRS = Nothing
Set objDC = Nothing
%>
<%end if%>
</html>
I'm trying to create a simple form that someone who has forgotten their password can enter their email address and, if the email matches the db, email them their password. I cannot find an example for doing this with JMail. I'm using ASP and a MS SQL database. The 'employers' db has the fields 'email' and 'pw'. I'm a newbie, so an example would be most helpful. Any assistance would be very much appreciated. Below is my trainwreck of code...
<!-- FORM PAGE -->
<form method="POST" action="sendpassword.asp">
E-mail Address:<input type="text" name="email" size="30">
<p><input type="submit" value="Send it"></p>
</form>
<!-- END FORM PAGE -->
<!-- FORM ACTION PAGE -->
<%@ LANGUAGE="VBSCRIPT" %>
<!-- DATABASE CONNECTION INCLUDE -->
<!-- #include file="db.inc" -->
<html>
<%
If (Request.Form("email") = "") Then
"SELECT * FROM Employers WHERE email = '" & email & "'"
%>
<head>
<title>Send Password</title>
</head>
<body>
<%
'checks if email address exists in the database before sending a message.
If objrs.EOF then
%>
<table border="0" cellPadding="0" cellSpacing="1" width="540">
<tr>
<td bgcolor="#FF0000"><font color="#FFFFFF"><b>Invalid Email Address</b></font></td>
</tr>
</table>
<p><span>We could not find</span><span> <%=email%></span>
<span> in our database.</span></p>
<% Else %>
<%
'sets variables
email = request.form("email")
'chooses email/username and password from database that correspond to submitted email address.
pass = objrs.Fields("pw")
Set JMail = Server.CreateObject("JMail.SMTPMail")
JMail.ServerAddress = "SERVER ADDRESS REMOVED FOR FORUM POST"
JMail.Sender = "SENDER ADDRESS REMOVED FOR FORUM POST"
JMail.Subject = "Your Password"
JMail.AddRecipient = email
JMail.Body = "Your user name and password are below as requested:" & vbCrLf
JMail.Body = JMail.Body & "Per your request your account login information is: " & vbCrlf & vbCrlf _
& "Password=" & pw & vbCrlf
JMail.Body = JMail.Body & "You may now use these to log on"
JMail.Priority = 3
JMail.Execute
%>
<p>We just sent your login information to <%=email%>.<br>
You should receive it shortly.</p>
<%
' Close Data Access Objects and free connection variables
objDC.Close
Set objRS = Nothing
Set objDC = Nothing
%>
<%end if%>
</html>