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

Creates an e-mail message with replacements 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, string body, System.Web.UI.Control owner)

Parameters

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

Returns

The e-mail message with replacements 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 with the System.Net.Mail.SmtpClient.Send(string, string, string, string) method.

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 body parameter contains the text of the e-mail message.

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