System
2.0.0.0
4.0.0.0
System.Object
System.IDisposable
Instances of the class are used to construct e-mail messages that are transmitted to an SMTP server for delivery using the class.
The sender, recipient, subject, and body of an e-mail message may be specified as parameters when a is used to initialize a object. These parameters may also be set or accessed using properties on the object.
The primary mail message headers and elements for the message may be set using the following properties of the class.
-
Mail header or part
Property
-
Attachments
-
Blind carbon copies (BCC)
-
Carbon copies (CC)
-
Content-Type
-
Encoding for custom headers
-
Message body
-
Priority
-
Recipient
-
Reply-To
-
Sender
-
Subject
The class also allows an application to access the headers collection for the message using the property. While this collection is read-only (a new collection can not be set), custom headers can be added to or deleted from this collection. Any custom headers added will be included when the instance is sent. Before a message is sent, only headers specifically added to this collection in the property are included in the collection. After a the instance is sent, the property will also include headers that are set using the associated properties of the class or parameters passed when a is used to initialize a object.
If some mail headers are malformed, they could cause the email message to become corrupted. So any mail header in the headers collection that can be set using a property on the class should only be set using the class property or as a parameter passed when a initializes a object. The following list of mail headers should not be added using the property and any values set for these headers using the property will be discarded or overwritten when the message is sent:
-
Bcc
-
Cc
-
Content-ID
-
Content-Location
-
Content-Transfer-Encoding
-
Content-Type
-
Date
-
From
-
Importance
-
MIME-Version
-
Priority
-
Reply-To
-
Sender
-
To
-
X-Priority
If the application does not specify an X-Sender header using the property, the class will create one when the message is sent.
Use the property to specify copies of an e-mail message in different formats. For example, if you send a message in HTML, you might also want to provide a plain text version in case some of the recipients use e-mail readers that cannot display HTML content. For an example that demonstrates creating a message with alternate views, see .
Use the property to add attachments to an e-mail message. For an example that demonstrates creating a message with an attachment, see .
After assembling your e-mail message, you can send it by using the or methods.
Represents an e-mail message that can be sent using the class.
Constructor
2.0.0.0
4.0.0.0
From is set to the value in the network element for mailSettings, if it exists.
Initializes an empty instance of the class.
Constructor
2.0.0.0
4.0.0.0
The property is initialized using and the property is initialized using .
Initializes a new instance of the class by using the specified class objects.
A that contains the address of the sender of the e-mail message.
A that contains the address of the recipient of the e-mail message.
Constructor
2.0.0.0
4.0.0.0
The property is initialized using and the property is initialized using .
Initializes a new instance of the class by using the specified class objects.
A that contains the address of the sender of the e-mail message.
A that contains the addresses of the recipients of the e-mail message.
Constructor
2.0.0.0
4.0.0.0
The properties for the new object are initialized as follows:
-
Parameter
Property
-
-
-
-
-
-
-
-
-
-
By default, the subject and content are assumed to use the default encoding based on local computer settings. Use the and properties to specify different encodings.
Initializes a new instance of the class.
A that contains the address of the sender of the e-mail message.
A that contains the address of the recipient of the e-mail message.
A that contains the subject text.
A that contains the message body.
Property
2.0.0.0
4.0.0.0
System.Net.Mail.AlternateViewCollection
To be added.
Use the property to specify copies of an e-mail message in different formats. For example, if you send a message in HTML, you might also want to provide a plain text version in case some of the recipients use e-mail readers that cannot display HTML content.
To add an alternate view to a object, create an for the view, and then add it to the collection returned by . Use the property to specify the text version and use the collection to specify views with other MIME types. Use the class members to specify the MIME type for the alternate view.
Gets the attachment collection used to store alternate forms of the message body.
Property
2.0.0.0
4.0.0.0
System.Net.Mail.AttachmentCollection
To be added.
Use the collection returned by the property to add an attachment, such as a file or the contents of a , to this .
Create an that contains or references the data to be attached, and then add the to the collection returned by .
Gets the attachment collection used to store data attached to this e-mail message.
Property
2.0.0.0
4.0.0.0
System.Net.Mail.MailAddressCollection
To be added.
To add a BCC recipient to an e-mail message, create a for the recipient's address, and then add that object to the collection returned by the property.
When recipients view an e-mail message, the addresses are usually not displayed.
Gets the address collection that contains the blind carbon copy (BCC) recipients for this e-mail message.
Property
2.0.0.0
4.0.0.0
System.String
To be added.
The of the content is "text/plain". Specify the encoding used for the body with the property.
If the body content is available in alternative formats that provide richer presentation options for the recipients, you can specify alternate views for the body content by using the property. For example, an application might choose to send both the plain text body and an HTML version of the message body. E-mail readers that can display HTML can present the HTML version of the body to the recipient, while readers that cannot display HTML will display the plain text version of the message instead.
Gets or sets the message body.
Property
2.0.0.0
4.0.0.0
System.Text.Encoding
To be added.
The value specified for the property sets the character set field in the Content-Type header. The default character set is "us-ascii".
If you set the property to , , or , the Framework selects a of for this .
Gets or sets the encoding used to encode the message body.
Property
2.0.0.0
4.0.0.0
System.Net.Mail.MailAddressCollection
To be added.
To add a CC recipient to an e-mail message, create a for the recipient's address and then add that object to the collection returned by the property.
Gets the address collection that contains the carbon copy (CC) recipients for this e-mail message.
Property
2.0.0.0
4.0.0.0
System.Net.Mail.DeliveryNotificationOptions
To be added.
To be added.
Gets or sets the delivery notifications for this e-mail message.
Method
2.0.0.0
4.0.0.0
System.Void
Call the method when you are finished using the . The method leaves the in an unusable state. After calling , you must release all references to the so the garbage collector can reclaim the memory that the was occupying. For more information, see Cleaning Up Unmanaged Resources and Implementing a Dispose Method.
Always call before you release your last reference to the .
Releases all resources used by the .
Method
2.0.0.0
4.0.0.0
System.Void
This method is called by the public Dispose() method and the method. Dispose() invokes the protected Dispose(Boolean) method with the parameter set to true. invokes Dispose with set to false.
When the parameter is true, this method releases all resources held by any managed objects that this references. This method invokes the Dispose() method of each referenced object.
Releases the unmanaged resources used by the and optionally releases the managed resources.
true to release both managed and unmanaged resources; false to release only unmanaged resources.
Property
2.0.0.0
4.0.0.0
System.Net.Mail.MailAddress
To be added.
The from address is not validated or tied to the currently logged on user.
Gets or sets the from address for this e-mail message.
Property
2.0.0.0
4.0.0.0
System.Collections.Specialized.NameValueCollection
To be added.
The property allows an application to access the headers collection for the message. While this collection is read-only (a new collection can not be set), custom headers can be added to or deleted from this collection. Any custom headers added will be included when the instance is sent. Before a message is sent, only headers specifically added to this collection in the property are included in the collection. After the instance is sent, the property will also include headers that are set using the associated properties of the class or parameters passed when a is used to initialize a object.
If some mail headers are malformed, they could cause the email message to become corrupted. So any mail header in the headers collection that can be set using a property on the class should only be set using the class property or as a parameter passed when a initializes a object. The following list of mail headers should not be added using the property and any values set for these headers using the property will be discarded or overwritten when the message is sent:
-
Bcc
-
Cc
-
Content-ID
-
Content-Location
-
Content-Transfer-Encoding
-
Content-Type
-
Date
-
From
-
Importance
-
MIME-Version
-
Priority
-
Reply-To
-
Sender
-
To
-
X-Priority
If the application does not specify an X-Sender header using the property, the class will create one when the message is sent.
The sender, recipient, subject, and body of an e-mail message may be specified as parameters when a is used to initialize a object. These parameters may also be set or accessed using properties on the object.
The primary mail message headers and elements for the message may be set using the following properties of the class.
-
Mail header or part
Property
-
Attachments
-
Blind carbon copies (BCC)
-
Carbon copies (CC)
-
Content-Type
-
Encoding for custom headers
-
Message body
-
Priority
-
Recipient
-
Reply-To
-
Sender
-
Subject
Gets the e-mail headers that are transmitted with this e-mail message.
Property
4.0.0.0
System.Text.Encoding
To be added.
The value of the property defaults to .
SMTP messages consist of headers and body parts. The IETF RFCs for SMTP restrict the header and body part names to be ASCII. However, the IETF RFCs allow header and body part values to contain Unicode characters. In any particular value, if non-ASCII characters exist, then the value is encoded using a combination of character encoding (UTF8 or Shift-JIS, for example) followed by byte encoding ( or for example). The result is usually that only ASCII characters are in the network transmission stream.
Gets or sets the encoding used for the user-defined custom headers for this e-mail message.
Property
2.0.0.0
4.0.0.0
System.Boolean
To be added.
To be added.
Gets or sets a value indicating whether the mail message body is in Html.
Property
2.0.0.0
4.0.0.0
System.Net.Mail.MailPriority
To be added.
To be added.
Gets or sets the priority of this e-mail message.
Property
2.0.0.0
4.0.0.0
System.Obsolete("Use ReplyToList instead")
System.Net.Mail.MailAddress
To be added.
Use the property to indicate an address other than the address to use to reply to this message.
Gets or sets the ReplyTo address for the mail message.
Property
4.0.0.0
System.Net.Mail.MailAddressCollection
To be added.
Use the property to indicate the list of addresses other than the address to use to reply to this message.
The property replaces the property that only allows a single address to reply to.
Gets or sets the list of addresses to reply to for the mail message.
Property
2.0.0.0
4.0.0.0
System.Net.Mail.MailAddress
To be added.
The sender's address is not validated or tied to the currently logged on user.
Gets or sets the sender's address for this e-mail message.
Property
2.0.0.0
4.0.0.0
System.String
To be added.
Specify the encoding used for the subject by using the property.
Gets or sets the subject line for this e-mail message.
Property
2.0.0.0
4.0.0.0
System.Text.Encoding
To be added.
If a mail agent has difficulty with a of , use .
Gets or sets the encoding used for the subject content for this e-mail message.
Property
2.0.0.0
4.0.0.0
System.Net.Mail.MailAddressCollection
To be added.
The property is used to designate the addresses on the To line of an e-mail message. To add a recipient to an e-mail message, create a for the recipient's address, and then add that object to the collection returned by this property.
Gets the address collection that contains the recipients of this e-mail message.