开发者

<asp:PasswordRecovery > How to Customise the E-mail sent to the user?

开发者 https://www.devze.com 2022-12-30 02:40 出处:网络
I have currently setup a basic开发者_Python百科 membership system in ASP.NET and have used the <asp:PasswordRecovery ID=\"PasswordRecovery1\" Runat=\"server\"></asp:PasswordRecovery>

I have currently setup a basic开发者_Python百科 membership system in ASP.NET and have used the

<asp:PasswordRecovery ID="PasswordRecovery1" Runat="server"></asp:PasswordRecovery>

To deal with the password recovery, Which Works great but how would one customise the e-mail such as changing the"Subject" and the actual body content of the e-mail ?


Implement the OnSendingMail event for the passwordrecovery control.

the parameter (MailMessageEventArgs e) is the MailMessage object and you can update the subject/body etc fields before the message is actually sent.


Please see David Winchester's answer at this link https://forums.asp.net/post/3167737.aspx

I've edited his answer as following:

<asp:PasswordRecovery ID="PasswordRecovery1" runat="server">
        <MailDefinition 
            From="noreply@gmail.com" 
            Subject="Your temporary password!" 
            IsBodyHtml="true" 
            Priority="High" 
            BodyFileName="~/Templates/PasswordRecoveryMail.htm">
        </MailDefinition>
    </asp:PasswordRecovery>

Content of PasswordRecoveryMail.htm file

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <div>
        Please return to the site and log in using the following information. 
    </div>
<p>Username: <%UserName%></p>
    <p>Password: <%Password%></p>
</body>
</html>


You can edit the MailDefinition settings.

MailDefinition-BodyFileName="uri"
MailDefinition-CC="string"
MailDefinition-From="string"
MailDefinition-IsBodyHtml="True|False"
MailDefinition-Priority="Normal|Low|High"
MailDefinition-Subject="string"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号