PasswordRecovery.MailDefinition 属性

定义

获取对属性集合的引用,这些属性定义用于向用户发送新的或恢复的密码的电子邮件的特性。

public:
 property System::Web::UI::WebControls::MailDefinition ^ MailDefinition { System::Web::UI::WebControls::MailDefinition ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.Web.UI.Themeable(false)]
public System.Web.UI.WebControls.MailDefinition MailDefinition { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
[<System.Web.UI.Themeable(false)>]
member this.MailDefinition : System.Web.UI.WebControls.MailDefinition
Public ReadOnly Property MailDefinition As MailDefinition

属性值

对 的引用, MailDefinition 其中包含定义用于向用户发送其密码的电子邮件的特征的属性。

属性

示例

下面的代码示例使用 SendingMail 事件通过设置 属性的 MailDefinition 子属性来定义密码电子邮件。

<%@ page language="C#" %>

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

  void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
  {
    e.Message.IsBodyHtml = false;
    e.Message.Subject = "New password on Web site.";
  }
    
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
      <asp:passwordrecovery 
         id="PasswordRecovery1" 
         runat="server"
         maildefinition-from="userAdmin@your.site.name.here"
         onsendingmail="PasswordRecovery1_SendingMail">
      </asp:passwordrecovery>
    </form>
  </body>
</html>
<%@ page language="VB" %>

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

  Sub PasswordRecovery1_SendingMail(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MailMessageEventArgs)

    e.Message.IsBodyHtml = False
    e.Message.Subject = "New password on Web site."
    
  End Sub
    
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
      <asp:passwordrecovery
         id="PasswordRecovery1" 
         runat="server" 
         maildefinition-from="userAdmin@your.site.name.here"
         onsendingmail="PasswordRecovery1_SendingMail">
      </asp:passwordrecovery>
    </form>
  </body>
</html>

注解

属性 MailDefinition 返回对一组属性的引用,这些属性用于定义发送给用户的密码电子邮件的格式和内容。 常见设置包括主题行和发件人的回信地址。 有关属性的完整列表,请参阅 MailDefinition 类。

此属性是只读的;但是,可以设置它返回的对象 MailDefinition 的属性。 可以在 窗体 Property-Subproperty中以声明方式设置这些属性,其中 Subproperty 表示 MailDefinition 类 (例如 MailDefinition-Subject) 的属性。 还可以以编程方式在窗体 Property.Subproperty 中 (设置属性, MailDefinition.Subject 例如,) 。

无法通过主题或样式表主题设置此属性。 有关详细信息,请参阅 ThemeableAttributeASP.NET 主题和外观

MailDefinition 对象创建电子邮件时,它将进行下表所示的替换。 替换文本不区分大小写。

替换文本 替换为
<%UserName%> 用户的网站用户名。
<%Password%> 用户恢复的密码。

IsBodyHtml如果 对象的 属性MailDefinitiontrue,则邮件内容将进行 HTML 编码,以防止邮件收件人的跨站点脚本安全漏洞。

适用于

另请参阅