为什么我的CDO.MESSAGE无法发送

时间:2015-01-15 23:23:48

标签: html mysql sql asp-classic

我的代码适用于用户忘记密码的情况。用户点击忘记密码,它将要求3个凭据,如用户名,ID,然后它将发送临时密码到电子邮件。现在,我一直坚持向用户发送电子邮件。当我运行代码时,它在第45行给出了一个错误,即"使用cdoConfig.Fields"说失踪其他。我无法弄清问题是什么。请帮忙。

谢谢大家。

DIM strUsername, strHealth, strFacility
strUsername = Request.Form("Set_Username")
''strPassword = Request.Form("Set_Password")
strHealth = Request.Form("Set_Health_System_Code")
strFacility = Request.Form("Set_Facility_Code")

IF strUsername <> "" THEN

    ''******************************** CHECK FOR DB CONNECTION VALIDATED credentials *******************************************************************************************************
    DIM mySQL, objRS, rs, mySQL2, rs2
    Set objRS = CreateObject("ADODB.Connection")
    objRS.Open "Provider=MSDASQL.1;Password=;Persist Security Info=True;User ID=**;Data Source=**"
    mySQL = "SELECT health_system_code, facility_code, username, email_addr  FROM *** WHERE username = '" & strUsername & "' AND health_system_code= '" & strHealth & "' AND facility_code = '" & strFacility & "'"
    Set rs = objRS.Execute(mySQL)
    RanPassword = RandomString

   '' mySQL2 = "SELECT email_addr  FROM ***t_user WHERE username = '" & strUsername & "' AND health_system_code= '" & strHealth & "' AND facility_code = '" & strFacility & "'"
    'Set rs2 = objRS.Execute(mySQL2)
    ''**********************************Insert random password generator **********************************************************************************************************

    DIM objPS, psSQL, ps
    Set objPS = CreateObject("ADODB.Connection")
    objPS.Open "Provider=MSDASQL.1;Password=**;Persist Security Info=True;User ID=**;Data Source=**"
    psSQL = "UPDATE ** SET **= md5('"& RanPassword &"') WHERE username = '" & strUsername & "' AND health_system_code= '" & strHealth & "' AND facility_code = '" & strFacility & "'"
    Set ps = objPS.Execute(psSQL)
    Set cdoConfig = CreateObject("CDO.Configuration") 

   IF rs.EOF THEN
       Response.Write "<div align='center'><br><br>Sorry, you entered wrong credentials. <br>Please click back on your browser and enter correct information.</div>"
   ELSE
       Set cdoConfig = CreateObject("CDO.Configuration") 

       With cdoConfig.Fields 
           .Item(cdoSendUsingMethod) = cdoSendUsingPort 
           .Item(cdoSMTPServer) = "***" 
           .Item(cdoSMTPAuthenticate) = 1 
           '' .Item(cdoSendUsername) = "<enter_username_here>" 
           '' .Item(cdoSendPassword) = "<enter_password_here>" 
           .Update 
       End With

       Set cdoMessage = CreateObject("CDO.Message") 

       With cdoMessage
           Set .Configuration = cdoConfig
           .From = "support@rxauditor.com"
           .To =  bs
           .Subject = "Forgotten Password"
           .HTMLBody = "<br>Testing</a><br><br>"
           .Send
       End With

       Response.Write(RanPassword)
       Response.Write "<br><div align='center'><br>Password has been reset and please check your email </a></div>"

    END IF

    objRS.Close
    Set objRS = Nothing
    objPS.Close
    Set objPS = Nothing

ELSE
    Response.Write ("<center><br><br>Please click back on your browser and enter your information.</center>")
END IF

0 个答案:

没有答案