2014-09-26 107 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

回复于rs_user( “密码”)上面呼叫sSendReminder。你看到价值了吗? – 2014-09-26 22:18:34

+0

再来。我没有得到你 – blay 2014-09-26 22:24:55

+0

我现在得到你,与response.write它能够写在页面上的密码,但不能发送邮件的正文 – blay 2014-09-27 00:30:14

回答

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 2014-09-27 08:49:15