System.Web.UI.WebControls.MailDefinition.CreateMailMessage Method

Creates an e-mail message from a text file to send by means of SMTP (Simple Mail Transfer Protocol).

Syntax

public System.Net.Mail.MailMessage CreateMailMessage (string recipients, IDictionary replacements, System.Web.UI.Control owner)

Parameters

recipients
A comma-separated list of message recipients.
replacements
An IDictionary containing a list of strings and their replacement strings.
owner
The System.Web.UI.Control that owns this System.Web.UI.WebControls.MailDefinition.

Returns

The e-mail message from a text file.

Remarks

The MailDefinition.CreateMailMessage(string, IDictionary, System.Web.UI.Control) method creates a new System.Net.Mail.MailMessage object that can be sent using the System.Net.Mail.SmtpClient.Send(string, string, string, string) method.

The System.Web.Mail.MailMessage.BodyFormat property must be set to indicate whether the mail message should be formatted as plain text (System.Web.Mail.MailFormat.Text) or HTML (System.Web.Mail.MailFormat.Html).

The recipients parameter contains a comma-separated list of recipients of the e-mail message. If the recipients parameter contains an improperly formatted Internet e-mail address, the System.Net.Mail.SmtpClient.Send(string, string, string, string) method throws an System.Web.HttpException exception and the e-mail message is not sent.

The replacements parameter is an IDictionary instance that contains a list of strings to substitute. Strings are replaced in the order in which they were added to the IDictionary collection, and they can overwrite earlier replacements.

The owner parameter indicates which control is the parent of the System.Web.UI.WebControls.MailDefinition control. It determines which directory to search for the text file specified in the MailDefinition.BodyFileName property.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0