PasswordRecovery.MailDefinition 属性   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取对属性集合的引用,这些属性定义用于向用户发送新密码或已恢复密码的电子邮件的特征。
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.MailDefinitionPublic 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)设置属性。
此属性不能由主题或样式表主题设置。 有关详细信息,请参阅 ThemeableAttribute 和 ASP.NET 主题和皮肤。
从 MailDefinition 对象创建电子邮件时,它将进行下表中显示的替换。 替换文本不区分大小写。
| 替换文本 | 替换为 | 
|---|---|
| <% UserName%> | 用户的网站用户名。 | 
| <%密码%> | 用户恢复的密码。 | 
如果 MailDefinition 对象的 IsBodyHtml 属性 true,则邮件的内容将进行 HTML 编码,以防止邮件收件人的跨站点脚本安全漏洞。