This documentation is archived and is not being maintained.

MailMessageEventArgs Class

Provides data for e-mail–related events.

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

<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class MailMessageEventArgs _
	Inherits LoginCancelEventArgs
Dim instance As MailMessageEventArgs

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="VB" %>
<%@ Import namespace="Samples.AspNet.VB.Controls" %>

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

  Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)

    Dim passwordRecoveryControl As New PasswordRecoveryOnBeforeSendingEmail

    passwordRecoveryControl.ID = "passwordRecoveryControl"
    passwordRecoveryControl.MailDefinition.From = ""

  End Sub


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


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 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