|
I almost have this working except for a few bugs. Basicly I want someone to enter their username and then the page will look up that entry and send the user their password to their email. The problem I am having is specifying the TO Email based on the entry you get back from the DB and the Body containing that enties information. Here is the code. I highlighted the two lines in question. Any suggesstions?
Thanks
If Request.querystring("mode") = "get" then
'Create an ADO connection object Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("toddwoolums_site.mdb")
strUserName = Request.Form("txtUserName")
IF strUserName = "" then Response.Redirect"password.asp?mode=blank" End If
'Create an ADO recordset object Set rsGetPassword = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database strSQL = "SELECT username, password, email from tblUsers where username = '" & strUserName & "'"
'Open the recordset with the SQL query rsGetPassword.Open strSQL, adoCon
'Reset server objects
If rsGetPassword.EOF then Response.Redirect"password.asp?mode=nouser" End If
Dim strEmail strEmail = rsGetPassword("email")
Response.Write ("Username is ") Response.Write (rsGetPassword("username")) Response.Write ("<br><br><br>") Response.Write ("Password is ") Response.Write (rsGetPassword("password")) Response.Write ("<br><br><br>") Response.Write ("Email is ") Response.Write (rsGetPassword("email")) Response.Write ("<br><br><br>")
'Dimension variables Dim objCDOMail 'Holds the CDONTS NewMail Object 'Create the e-mail server object Set objCDOMail = Server.CreateObject("CDONTS.NewMail") 'Who the e-mail is from objCDOMail.From = " mailto:twooly@mchsi.com - m ine@email.com" 'Who the e-mail is sent to objCDOMail.To = rsGetPassword("email") 'Set the subject of the e-mail objCDOMail.Subject = "Lost Password" 'Set the e-mail body format (0=HTML 1=Text) objCDOMail.BodyFormat = 0 'Set the mail format (0=MIME 1=Text) objCDOMail.MailFormat = 0 'Set the main body of the e-mail objCDOMail.Body = "Password is: '" & rsGetPassword("password") "'" 'Importance of the e-mail (0=Low, 1=Normal, 2=High) objCDOMail.Importance = 1 'Send the e-mail objCDOMail.Send 'Close the server object Set objCDOMail = Nothing
Set rsGetPassword = Nothing Set adoCon = Nothing
End If
|