PasswordRecovery.SendingMail Event

Definition

Occurs before the user is sent a password in email.

C#
public event System.Web.UI.WebControls.MailMessageEventHandler SendingMail;

Event Type

Examples

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

ASP.NET (C#)
<%@ 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>

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

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also