Message Property
Collapse the table of content
Expand the table of content

MailMessageEventArgs.Message Property

 

Gets the e-mail message contents.

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

Public ReadOnly Property Message As MailMessage

Property Value

Type: System.Net.Mail.MailMessage

A MailMessage containing the message contents.

The Message property returns the MailMessage object that contains the e-mail message data. The Message property is read-only; however, you can use the MailMessage object that it returns to modify the properties of the e-mail message.

The following code example demonstrates how to use the Message property 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 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>

.NET Framework
Available since 2.0
Return to top
Show:
© 2016 Microsoft