SendingMail Event

PasswordRecovery.SendingMail Event

Occurs before the user is sent a password in e-mail.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public event MailMessageEventHandler SendingMail
<asp:PasswordRecovery OnSendingMail="MailMessageEventHandler" />

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 e-mail. Use this event to do any special processing required before sending the e-mail 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 e-mail. The e-mail uses the settings defined in the smtp configuration file element.

For more information about handling events, see Consuming Events.

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

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<script runat="server">

  void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
    e.Message.IsBodyHtml = false;
    e.Message.Subject = "New password on Web site.";


<html xmlns="" >
  <head runat="server">
    <title>ASP.NET Example</title>
    <form id="form1" runat="server">

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

© 2015 Microsoft