Hey guys , hows it going? I have this change password code which updates the user's password successfully but it cant send an auto email once the user's password has been updated. No errors when I tested it ,just no emails was received. can anyone tell me what I shall need to amend.below is the form and the processing page. the form Change your password? Type your password to a new one <br> <%=msg%> <form method="POST" action="change-process.asp" onSubmit="return validateform();"> <input type="hidden" name="hiddenval"> <% If Request.Cookies("User_Name") <> "" then Logged = 1 else %> <b> <font size="-2" color="#FF0000"> You may have to <a href="login.asp">login </a> before you can change password </font> </b> <br /> <br /> <% Logged = 0 end if %> <br> <input type="hidden" name="user_name" value="<%=Request.Cookies("User_Name")%>" /> <table width="350" border="1" cellspacing="0" cellpadding="5"> <tr> <td>User Name </td> <td><%=Request.Cookies("User_Name")%></td> </tr> <tr> <td>Current Password</td> <td><input type="password" name="pwd1" /> </td> </tr> <tr> <td>New Password </td> <td><input type="password" name="pwd2" /> </td> </tr> <tr> <td>Repeat New Password </td> <td><input type="password" name="pwd3" /> </td> </tr> <tr> <td>Email </td> <td><input type="Email" name="Personal_Email" size="20"></td> </tr> <tr> <td> </td> <td><input name="Submit" type="submit" id="Update" onClick="submitform('change-process.asp')" value="Update Password"> </td> </tr> </table> </form> Code (markup): the processing page <% Response.Buffer = True //strUserName = Request.Cookies("User_Name") //strPassword = Request.Cookies("User_Password") user = request.form("User_Name") emailadd=Request.Form("Personal_Email") Dim errMsg, vPath, pPath, ConString, conn, rs Dim strBody1 Dim strSubject1 errMsg = "" vPath = "BMP.mdb" pPath = Server.MapPath(vPath) ConString = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & pPath & ";" & "JET OLEDB:" Set conn = Server.CreateObject("ADODB.Connection") conn.Open ConString set rs = Server.CreateObject("ADODB.recordset") Function checkPass(password) sqlStr = "SELECT User_Password" _ & " FROM Customer" _ & " WHERE User_Password = '" & strPassword & "'" _ & " AND User_Name = '" & user & "'" rs.Open sqlStr, conn If rs.EOF Then checkPass = false else checkPass = true End If rs.Close conn.Close set rs = nothing set conn = nothing End Function If Request.Form("Update") <> "" Then strpassword = Trim(Request.Form("pwd1")) new_password1 = Trim(Request.Form("pwd2")) new_password2 = Trim(Request.Form("pwd3")) If strpassword = "" Then errMsg = errMsg & "-Please enter your current password<br>" elseif new_password1 = "" or new_password2 = "" then errMsg = errMsg & "-Please enter your new password<br>" elseif new_password1 <> new_password2 then errMsg = errMsg & "-Your new passwords do not match<br>" ElseIf checkPass(strpassword) = false Then errMsg = errMsg & "-Current Password does not match your password in the database<br>" End If If errMsg <> "" Then msg = errMsg 'print msg or redirect to another page to display the error message Response.write msg Else strNewPassword = new_password1 sqlStr = "UPDATE Customer SET" _ & " User_Password = '" & strNewPassword & "'" _ & " WHERE User_Name = '" & user & "'" conn.Execute sqlStr msg = "-Password Updated<br>" strBody1 = " Here is your username & password. We look forward to your patronise to our online store." & "<BR>" & "User's Name:"&user& "<BR>" & "Your Password:"& strNewPassword 'set your user name cookie value here Response.Cookies("User_Name") = user 'send mail SendMail() Response.Redirect("login.asp") End If End If Sub SendMail() strSubject1 = "Password Retrieved, from Mellon Commercial www.xxx.com.sg " &user Dim str_HTML1 , Mailer str_HTML1 = str_HTML1 & "<html>" str_HTML1 = str_HTML1 & "<body bgcolor='#FFFFFF'><BR>" str_HTML1 = str_HTML1 & "<p align='left'>" str_HTML1 = str_HTML1 & "<TABLE><TR><TD>" str_HTML1 = str_HTML1 & "<font color='#0000FF' face='TAHOMA' size='2'>" str_HTML1 = str_HTML1 & strLine & strSubject1 &"<BR>" & strBody1 & "<BR>" str_HTML1 = str_HTML1 & "</p>" str_HTML1 = str_HTML1 & "</font>" str_HTML1 = str_HTML1 & "</TR></TD></TABLE>" str_HTML1 = str_HTML1 & "</body>" str_HTML1 = str_HTML1 & "</html>" ' Set the object to nothing because it immediately becomes invalid after calling the Send method + it clears it out of the Server's Memory. Set Mailer = Nothing 'Email the customer Dim getUserEmail Set CustMailer = Server.CreateObject("CDO.Message") CustMailer.To = emailadd CustMailer.From = "sales@xxx.com.sg" CustMailer.Subject = strSubject1 CustMailer.HTMLBody = str_HTML1 CustMailer.Send Set CustMailer = Nothing end sub 'Response.Redirect("login.asp") 'tell the user their account is added 'Response.Redirect("login.asp") %> Code (markup):
Prior to the Send Method of the CustMailer, please define the Mail Sending Properties: CustMailer.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 CustMailer.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.server.com" CustMailer.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25 CustMailer.Configuration.Fields.Update Put this directly after the Set CustMailer = Server.CreateObject("...
Ok 2 things, /// <%=Request.Cookies("User_Name")%> Although you show it in your page, you need to put it to be posted, such as: <input type="hidden" name="User_Name" value="<%=Request.Cookies("User_Name")%>" /> /// <input type="Email" name="Personal_Email" size="20"> And, type = Email, should be type="input" IE just fixing your code for you I guess.