Export (0) Print
Expand All

MailMessageEventArgs Class

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

Provides data for e-mail–related events.

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

public class MailMessageEventArgs : LoginCancelEventArgs
public class MailMessageEventArgs extends LoginCancelEventArgs
public class MailMessageEventArgs extends LoginCancelEventArgs

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>

System.Object
   System.EventArgs
     System.Web.UI.WebControls.LoginCancelEventArgs
      System.Web.UI.WebControls.MailMessageEventArgs

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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:
© 2014 Microsoft