Redigera

Dela via


PasswordRecovery.SendingMail Event

Definition

Occurs before the user is sent a password in email.

public:
 event System::Web::UI::WebControls::MailMessageEventHandler ^ SendingMail;
public event System.Web.UI.WebControls.MailMessageEventHandler SendingMail;
member this.SendingMail : System.Web.UI.WebControls.MailMessageEventHandler 
Public Custom Event SendingMail As MailMessageEventHandler 

Event Type

Examples

The following code example uses the SendingMail event to set properties of the MailMessage object that contains the email message.

<%@ 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 SendingMail event occurs on the server after the user requests a new or recovered password and submits a correct answer to the password confirmation question (if your membership provider supports password question and answer), but before the password is sent to the user in email. Use this event to do any special processing required before sending the email message, such as setting MailMessage properties.

After the user enters a valid user name and, if relevant, a valid answer, the PasswordRecovery control raises the SendingMail event, and then sends the password information to the user in email. The email uses the settings defined in the <smtpMail> configuration file element.

For more information about how to handle events, see Handling and Raising Events.

Applies to

See also