2017-04-06 55 views
0

我们使用内置的asp.net会员供应商来处理用户帐户。提供商创建的默认临时密码对于我们的用户来说有些过于复杂,因此我使用下面的代码来生成一个更容易输入的密码,以便他们可以重置密码。它完全可以生成新的密码,并且会员提供商正在使用它而不是复杂的密码。电子邮件中的ASP.NET会员供应商密码替换

这是我的问题所在:当用户请求临时密码时,应用程序会通过电子邮件发送给他们。我试图用我生成的密码替换临时密码。您可以在下面的屏幕截图中看到,我生成的密码附加在电子邮件的底部,但我无法将<%Password%>替换为我的新密码。我错过了什么?

Public Sub PasswordRecovery1_SendingMail(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MailMessageEventArgs) Handles PasswordRecovery1.SendingMail 
    Dim User As MembershipUser = Membership.GetUser(PasswordRecovery1.UserName) 
    Dim msg As String = e.Message.Body 

    Dim oldpswd As String = User.ResetPassword() 
    Dim newpass As String = GetPassword() 

    msg.Replace("<%Password%>", newpass) 

    msg += "<p>Your new password is: " & newpass & "</p>" 
    User.ChangePassword(oldpswd, newpass) 

    e.Message.Body = msg 
End Sub 

Email Template I'd like to update with newpass

Email that goes to user still has old password and new one at the bottom

+0

我尝试用新密码更新电子邮件模板的图像。 – DalW

回答

0

取代他们的是 “<%密码%>” “< -TemporaryPasswordArea>” 我的模板,然后改变了味精分配到下面,它的正确替换它在电子邮件中。

msg = msg.Replace("<-TemporaryPasswordArea>", newpass)