MailMessageEventArgs Class
Assembly: System.Web (in system.web.dll)
The MailMessageEventArgs class provides access to the MailMessage object that contains the e-mail message. Because the MailMessageEventArgs class is derived from the LoginCancelEventArgs class, you can cancel sending an e-mail message in your event handler by setting the Cancel property to true.
The following code example demonstrates how to use the MailMessageEventArgs class in an e-mail message event handler to change the contents of the message before it is sent.
<%@ page language="C#" %> <%@ Import namespace="Samples.AspNet.CS.Controls" %> <script runat="server"> void Page_Init(object sender, EventArgs e) { PasswordRecoveryOnBeforeSendingEmail passwordRecoveryControl = new PasswordRecoveryOnBeforeSendingEmail(); passwordRecoveryControl.ID = "passwordRecoveryControl"; passwordRecoveryControl.MailDefinition.From = "userAdmin@your.site.name.here"; PlaceHolder1.Controls.Add(passwordRecoveryControl); } </script> <html> <body> <form runat="server"> <asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder> </form> </body> </html>
- AspNetHostingPermission for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
System.EventArgs
System.Web.UI.WebControls.LoginCancelEventArgs
System.Web.UI.WebControls.MailMessageEventArgs
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.