Επεξεργασία

Κοινή χρήση μέσω


PasswordRecovery.MailDefinition Property

Definition

Gets a reference to a collection of properties that define the characteristics of email messages used to send new or recovered passwords to users.

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

Property Value

A reference to a MailDefinition that contains properties that define the characteristics of email messages used to send users their passwords.

Attributes

Examples

The following code example uses the SendingMail event to define the password email message by setting subproperties of the MailDefinition property.

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

Remarks

The MailDefinition property returns a reference to a group of properties that you use to define format and content of the password email message sent to users. Common settings include the subject line and the sender's return address. For a complete list of properties, see the MailDefinition class.

This property is read-only; however, you can set the properties of the MailDefinition object it returns. You can set these properties declaratively in the form Property-Subproperty, where Subproperty represents a property of the MailDefinition class (for example, MailDefinition-Subject). You can also set the properties programmatically in the form Property.Subproperty (for example, MailDefinition.Subject).

This property cannot be set by themes or style sheet themes. For more information, see ThemeableAttribute and ASP.NET Themes and Skins.

When the email message is created from the MailDefinition object, it will make the substitutions shown in the following table. The substitution text is case-insensitive.

Substitution text Replaced with
<% UserName %> The Web site user name of the user.
<% Password %> The recovered password for the user.

If the IsBodyHtml property of the MailDefinition object is true, the contents of the mail message will be HTML encoded to guard against cross-site scripting security vulnerabilities for the message recipient.

Applies to

See also