.NET Framework Class Library MailMessageEventArgs Class Provides data for e-mail–related events.

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

Syntax
Public Class MailMessageEventArgs _
Inherits LoginCancelEventArgs
public class MailMessageEventArgs : LoginCancelEventArgs
public ref class MailMessageEventArgs : public LoginCancelEventArgs
type MailMessageEventArgs =
class
inherit LoginCancelEventArgs
end
The MailMessageEventArgs type exposes the following members.

Constructors

Properties

Methods

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

Examples
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"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 = "userAdmin@your.site.name.here"
PlaceHolder1.Controls.Add(passwordRecoveryControl)
End Sub
</script>
<html >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder>
</form>
</body>
</html>
<%@ page language="C#" %>
<%@ Import namespace="Samples.AspNet.CS.Controls" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder>
</form>
</body>
</html>

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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

See Also
|
Bibliothèque de classes .NET Framework MailMessageEventArgs, classe Fournit des données pour les événements relatifs aux messages électroniques.

Hiérarchie d'héritage
Espace de noms :
System.Web.UI.WebControls
Assembly :
System.Web (dans System.Web.dll)

Syntaxe
Public Class MailMessageEventArgs _
Inherits LoginCancelEventArgs
public class MailMessageEventArgs : LoginCancelEventArgs
public ref class MailMessageEventArgs : public LoginCancelEventArgs
type MailMessageEventArgs =
class
inherit LoginCancelEventArgs
end
Le type MailMessageEventArgs expose les membres suivants.

Constructeurs

Propriétés

Méthodes

Notes
La classe MailMessageEventArgs donne accès à l'objet MailMessage qui contient le message électronique. Étant donné que la classe MailMessageEventArgs est dérivée de la classe LoginCancelEventArgs, vous pouvez annuler l'envoi d'un message électronique dans votre gestionnaire d'événements en affectant la valeur true à la propriété Cancel.

Exemples
L'exemple de code suivant montre comment utiliser la classe MailMessageEventArgs dans un gestionnaire d'événements de message électronique pour modifier le contenu du message avant de l'envoyer.
<%@ page language="VB" %>
<%@ Import namespace="Samples.AspNet.VB.Controls" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 = "userAdmin@your.site.name.here"
PlaceHolder1.Controls.Add(passwordRecoveryControl)
End Sub
</script>
<html >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder>
</form>
</body>
</html>
<%@ page language="C#" %>
<%@ Import namespace="Samples.AspNet.CS.Controls" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder>
</form>
</body>
</html>

Informations de version
.NET FrameworkPris en charge dans : 4, 3.5, 3.0, 2.0

Plateformes
Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

Sécurité des threads
Tous les membres static ( Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Voir aussi
RéférenceAutres ressources
|