2014-09-26 2 views
0

저는 asp로 프로젝트를 진행하고 있는데, 사용자가 자신의 이메일을 입력 한 곳을 잊어 버렸고 유효하면 암호를 보냅니다. 이제 문제는 이메일이 데이터베이스에 제대로 있는지 확인하고 메일을 보내지 만 패스워드를 보낼 수 없다는 것입니다.사용자가 잊어 버린 경우 암호를 보내십시오.

<% 

'Check if the form has been processed 
If Request.Form("process")="true" Then 
    'Check the recordset for a valid record 


    If Not rs_user.Eof Then 
    'Valid record, so proceed with the email 
    Call sSendReminder (rs_user("email"), rs_user("password")) 
    Response.Write "Your password has been sent to your inbox. If you don't find it in your mail box, check your junk mail folder" 


    dim sName, sEmail, sMessage 
    dim oCdoMail, oCdoConf, sConfURL 


    sEmail = Request.Form("email") 


     Set oCdoMail = Server.CreateObject("CDO.Message") 
     Set oCdoConf = Server.CreateObject("CDO.Configuration") 

     sConfURL = "http://schemas.microsoft.com/cdo/configuration/" 



     with oCdoConf 
      .Fields.Item(sConfURL & "sendusing") = 2 
      .Fields.Item(sConfURL & "smtpserver") = "smptserveraddress.com" 
      .Fields.Item(sConfURL & "smtpserverport") = 25 
      .Fields.Update 


     end with 

     with oCdoMail 
      .From = "[email protected]" 
      .To = sEmail 
      .Subject = "Password Recovery from samplesite" 
      .TextBody = "Your password is: " & password 
      .HTMLBody = "Your password is: " & password 
      .Configuration = oCdoConf 
      .Send 
     end with 

     Set oCdoConf = Nothing 
     Set oCdoMail = Nothing 


    Else 
    'Not a valid record 
    Response.Write "Sorry, no email was found." 
    End If 
End If 

     Sub sSendReminder(email, password) 

End Sub 

%>

+0

을 Response.Write의 rs_user ("비밀번호")를 호출 sSendReminder 위. 가치가 보이십니까? –

+0

가 다시 나타납니다. 나는 당신을 얻지 못한다. – blay

+0

나는 response.write를 사용하여 페이지에 암호를 쓸 수 있지만 메일 본문에 보낼 수 없다. – blay

답변

0

은 위의 코드를 실행중인 정확한 코드인가? 그래서, 당신은

Sub sSendReminder(email, password) 

dim sName, sEmail, sMessage 

이상을 이동해야하는 경우

은 또한 그 이동 하위 외부 문 "만약 종료"할 필요가있다.

기술적으로 올바르므로 코드가 실행되지만 하위가 실제로 비어 있어야한다고 생각하는 것처럼 실행되지 않습니다.

올바른 코드는 다음과 같습니다

<% 
 

 
'Check if the form has been processed 
 
If Request.Form("process")="true" Then 
 
    'Check the recordset for a valid record 
 

 

 
If Not rs_user.Eof Then 
 
    'Valid record, so proceed with the email 
 
    Call sSendReminder (rs_user("email"), rs_user("password")) 
 
    Response.Write "Your password has been sent to your inbox. If you don't find it in your mail box, check your junk mail folder" 
 
Else 
 
    'Not a valid record 
 
    Response.Write "Sorry, no email was found." 
 
    End If 
 
End If 
 
\t 
 
\t 
 
\t 
 
Sub sSendReminder(email, password) 
 

 
    dim sName, sEmail, sMessage 
 
    dim oCdoMail, oCdoConf, sConfURL 
 

 

 
    sEmail = Request.Form("email") 
 

 

 
     Set oCdoMail = Server.CreateObject("CDO.Message") 
 
     Set oCdoConf = Server.CreateObject("CDO.Configuration") 
 

 
     sConfURL = "http://schemas.microsoft.com/cdo/configuration/" 
 

 

 

 
     with oCdoConf 
 
      .Fields.Item(sConfURL & "sendusing") = 2 
 
      .Fields.Item(sConfURL & "smtpserver") = "smptserveraddress.com" 
 
      .Fields.Item(sConfURL & "smtpserverport") = 25 
 
      .Fields.Update 
 

 

 
     end with 
 

 
     with oCdoMail 
 
      .From = "[email protected]" 
 
      .To = sEmail 
 
      .Subject = "Password Recovery from samplesite" 
 
      .TextBody = "Your password is: " & password 
 
      .HTMLBody = "Your password is: " & password 
 
      .Configuration = oCdoConf 
 
      .Send 
 
     end with 
 

 
     Set oCdoConf = Nothing 
 
     Set oCdoMail = Nothing 
 
End Sub %>

+0

감사합니다. 예수님, 당신의 거친 상상을 초월하여 축복하십시오. – blay

관련 문제