Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

PasswordRecovery.SendingMail Event

Note: This event is new in the .NET Framework version 2.0.

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
/** @event */
public void add_SendingMail (MailMessageEventHandler value)

/** @event */
public void remove_SendingMail (MailMessageEventHandler value)

JScript supports the use of events, but not the declaration of new ones.

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 <smtpMail> 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#" %>

<script runat="server">

  void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
  {
    e.Message.IsBodyHtml = false;
    e.Message.Subject = "New password on Web site.";
  }
    
</script>

<html>
  <body>
    <form runat="server">
      <asp:passwordrecovery 
         id="PasswordRecovery1" 
         runat="server"
         maildefinition-from="userAdmin@your.site.name.here"
         onsendingmail="PasswordRecovery1_SendingMail">
      </asp:passwordrecovery>
    </form>
  </body>
</html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2015 Microsoft