MailMessageEventArgs.Message プロパティ

定義

電子メール メッセージの内容を取得します。

public:
 property System::Net::Mail::MailMessage ^ Message { System::Net::Mail::MailMessage ^ get(); };
public System.Net.Mail.MailMessage Message { get; }
member this.Message : System.Net.Mail.MailMessage
Public ReadOnly Property Message As MailMessage

プロパティ値

MailMessage

メッセージの内容を格納している MailMessage

次のコード例は、電子メール メッセージ イベント ハンドラーでプロパティを Message 使用して、メッセージが送信される前にメッセージの内容を変更する方法を示しています。

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

注釈

このプロパティは MessageMailMessage 電子メール メッセージ データを含むオブジェクトを返します。 プロパティは Message 読み取り専用です。ただし、返されるオブジェクトを MailMessage 使用して、電子メール メッセージのプロパティを変更できます。

適用対象

こちらもご覧ください