【问题标题】:<asp:PasswordRecovery > How to Customise the E-mail sent to the user?<asp:PasswordRecovery > 如何自定义发送给用户的电子邮件?
【发布时间】:2010-05-14 15:16:51
【问题描述】:

我目前已经在 ASP.NET 中建立了一个基本的会员系统并使用了

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

要处理密码恢复,Which Works 很好,但是如何自定义电子邮件,例如更改“主题”和电子邮件的实际正文内容?

【问题讨论】:

    标签: asp.net asp.net-membership password-recovery customising


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      您可以编辑MailDefinition 设置。

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

      【讨论】:

      • 如何更改邮件内容?
      【解决方案3】:

      请在此链接上查看 David Winchester 的回答 https://forums.asp.net/post/3167737.aspx

      我将他的答案编辑如下:

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

      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>
      

      【讨论】:

        猜你喜欢
        • 2021-01-05
        • 1970-01-01
        • 1970-01-01
        • 2019-10-19
        • 2020-04-16
        • 1970-01-01
        • 1970-01-01
        • 2022-07-04
        • 2020-02-01
        相关资源
        最近更新 更多