MailMessageEventArgs.Message Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the email message contents.
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
Property Value
A MailMessage containing the message contents.
Examples
The following code example demonstrates how to use the Message property in an email message event handler to change the contents of the message before it is sent.
<%@ 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>
Remarks
The Message property returns the MailMessage object that contains the email message data. The Message property is read-only; however, you can use the MailMessage object that it returns to modify the properties of the email message.
Applies to
See also
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈