MailDefinition.CreateMailMessage Method (String, IDictionary, Control)
Assembly: System.Web (in system.web.dll)
public:
MailMessage^ CreateMailMessage (
String^ recipients,
IDictionary^ replacements,
Control^ owner
)
public MailMessage CreateMailMessage ( String recipients, IDictionary replacements, Control owner )
public function CreateMailMessage ( recipients : String, replacements : IDictionary, owner : Control ) : MailMessage
Not applicable.
Parameters
- recipients
A comma-separated list of message recipients.
- replacements
An IDictionary containing a list of strings and their replacement strings.
- owner
The Control that owns this MailDefinition.
Return Value
A new MailMessage object.The CreateMailMessage method creates a new MailMessage object that can be sent using the System.Net.Mail.SmtpClient.Send(System.String,System.String,System.String,System.String) method.
The 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 Send method throws an 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 MailDefinition control. It determines which directory to search for the text file specified in the BodyFileName property.
The following code example creates a ListDictionary object that defines two strings ("<%To%>" and "<%From%>") that are replaced in the e-mail message.
This code example is part of a larger example provided for the MailDefinition class.
The following code example uses the CreateMailMessage method to create a new e-mail message from a text file.
This code example is part of a larger example provided for the MailDefinition class.