This class encapsulates an email message. To send an email message
programmatically, create a MailMessage object, set
the appropriate properties, and use the SmtpMail.Send(
) method.
The properties of the MailMessage class are fairly
straightforward and include all the typical details entered in an
email program, such as subject, priority, and the email addresses for
the sender, recipient, and any carbon-copied recipients (all as
strings). You can also use the Attachments
collection to add MailAttachment objects to a
message.
The actual body of the email message is set as a string through the
Body property. You will have to add line return
characters as required. If you set the BodyFormat
property to MailFormat.Html, you can also insert
standard HTML markup tags.
public class MailMessage {
// Public Constructors
public MailMessage( );
// Public Instance Properties
public IList Attachments{get; }
public string Bcc{set; get; }
public string Body{set; get; }
public Encoding BodyEncoding{set; get; }
public MailFormat BodyFormat{set; get; }
public string Cc{set; get; }
public IDictionary Fields{get; }
public string From{set; get; }
public IDictionary Headers{get; }
public MailPriority Priority{set; get; }
public string Subject{set; get; }
public string To{set; get; }
public string UrlContentBase{set; get; }
public string UrlContentLocation{set; get; }
}