MailMessageEventArgs 类

定义

为与电子邮件相关的事件提供数据。

public ref class MailMessageEventArgs : System::Web::UI::WebControls::LoginCancelEventArgs
public class MailMessageEventArgs : System.Web.UI.WebControls.LoginCancelEventArgs
type MailMessageEventArgs = class
    inherit LoginCancelEventArgs
Public Class MailMessageEventArgs
Inherits LoginCancelEventArgs
继承
MailMessageEventArgs

示例

下面的代码示例演示如何使用 MailMessageEventArgs 电子邮件事件处理程序中的类在发送邮件之前更改邮件的内容。

<%@ 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 xmlns="http://www.w3.org/1999/xhtml" >
  <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="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 xmlns="http://www.w3.org/1999/xhtml" >
  <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>

注解

MailMessageEventArgs 类提供对 MailMessage 包含电子邮件的对象的访问权限。 Because the MailMessageEventArgs class is derived from the LoginCancelEventArgs class, you can cancel sending an email message in your event handler by setting the Cancel property to true.

构造函数

MailMessageEventArgs(MailMessage)

创建 MailMessageEventArgs 类的新实例。

属性

Cancel

获取或设置指示是否应取消事件的值。

(继承自 LoginCancelEventArgs)
Message

获取电子邮件内容。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于

另请参阅