Allows a control to create e-mail messages from text files or strings. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
Thetype exposes the following members.
|BodyFileName||Gets or sets the name of the file that contains text for the body of the e-mail message.|
|CC||Gets or sets a comma-separated list of e-mail addresses to send a copy (CC) of the message to.|
|EmbeddedObjects||Gets a collection of EmbeddedMailObject instances, typically used to embed images in a object before sending an e-mail to a user.|
|From||Gets or sets the e-mail address of the message sender.|
|IsBodyHtml||Gets or sets a value indicating whether the body of the e-mail is HTML.|
|Priority||Gets or sets the priority of the e-mail message.|
|Subject||Gets or sets the subject line of the e-mail message.|
|CreateMailMessage(String, IDictionary, Control)||Creates an e-mail message from a text file to send by means of SMTP (Simple Mail Transfer Protocol).|
|CreateMailMessage(String, IDictionary, String, Control)||Creates an e-mail message with replacements from a text file to send by means of SMTP (Simple Mail Transfer Protocol).|
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
|IStateManager.IsTrackingViewState||Gets a value that indicates whether the server control is saving changes to its view state.|
|IStateManager.LoadViewState||Restores view-state information from a previous page request that was saved by the SaveViewState method.|
|IStateManager.SaveViewState||Saves any server control view-state changes that have occurred since the time the page was posted back to the server.|
|IStateManager.TrackViewState||Causes tracking of view-state changes to the server control so they can be stored in the server control's StateBag object.|
The class can be used by controls to create a MailMessage object from a text file or a string that contains the body of the e-mail message. Use the class to simplify creating predefined e-mail messages to be sent by a control. If you want to send e-mail not using a control, see the System.Net.Mail class.
The MailMessage object created by the class is sent using the Send method of the SmtpClient class. To be able to send e-mail, you must configure an SMTP mail server in your Web.config file. For more information, see the <smtp> Element (Network Settings).
The class does not support data binding. Properties of the class cannot be bound to data using the <%# %> data-binding expression syntax.
The following code example creates an Internet e-mail message from a Web Forms page. You can either enter the text of the message in the form or enter the name of a text file to use as the body of the mail. The code defines two string replacements for the message: the recipient list from the form's To text box will replace the string "<%To%>", and the text specified in the From property will replace the string "<%From%>".
On the Web Forms page that this code generates, you can click Create e-mail and display only to create an e-mail message and display the properties of the MailMessage object in the Web page. Click Create e-mail and send to both display the e-mail message in the Web page and send the message to the recipients using Internet e-mail.
This control has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), 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.