如何自定义发送给用户的电子邮件?

发布于 2024-09-01 17:39:37 字数 223 浏览 5 评论 0原文

我目前已经在 ASP.NET 中设置了一个基本的会员系统,并使用了 来

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

处理密码恢复,这非常有效,但是如何自定义电子邮件,例如更改“主题”和电子邮件的实际正文内容-邮件 ?

I have currently setup a basic 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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鹊巢 2024-09-08 17:39:37

为密码恢复控件实现 OnSendingMail 事件。

参数 (MailMessageEventArgs e) 是 MailMessage 对象,您可以在消息实际发送之前更新主题/正文等字段。

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.

又怨 2024-09-08 17:39:37

请在此链接查看大卫·温彻斯特的回答
https://forums.asp.net/post/3167737.aspx

我已经将他的答案编辑如下:

<asp:PasswordRecovery ID="PasswordRecovery1" runat="server">
        <MailDefinition 
            From="[email protected]" 
            Subject="Your temporary password!" 
            IsBodyHtml="true" 
            Priority="High" 
            BodyFileName="~/Templates/PasswordRecoveryMail.htm">
        </MailDefinition>
    </asp:PasswordRecovery>

PasswordRecoveryMail.htm 文件的内容

<!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>

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="[email protected]" 
            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>
甩你一脸翔 2024-09-08 17:39:37

您可以编辑 MailDefinition 设置。

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

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"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文