Name

MailMessage

Synopsis

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 (for example msg.Body = "Hi Bob, " & System.Environment.NewLine & "This is it!") 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 Sub New() 
' Public Instance Properties
   Public ReadOnly Property Attachments As IList  
   Public Property Bcc As String  
   Public Property Body As String  
   Public Property BodyEncoding As Encoding  
   Public Property BodyFormat As MailFormat  
   Public Property Cc As String  
   Public Property From As String  
   Public ReadOnly Property Headers As IDictionary  
   Public Property Priority As MailPriority  
   Public Property Subject As String  
   Public Property To As String  
   Public Property UrlContentBase As String  
   Public Property UrlContentLocation As String  
End Class

Get ASP.NET in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.