EmailAddress Class |
Namespace: MailBee.Mime
The EmailAddress type exposes the following members.
Name | Description | |
---|---|---|
EmailAddress | Initializes a new instance of the EmailAddress class | |
EmailAddress(String) |
Initializes a new instance of the EmailAddress object with the specified e-mail address.
| |
EmailAddress(String, String) |
Initializes a new instance of the EmailAddress object from the specified e-mail address and display name.
| |
EmailAddress(String, String, String) |
Initializes a new instance of the EmailAddress object from the specified e-mail address parts.
|
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
EscapeIdnDomain |
Converts domain part of e-mail address string into IDN format.
| |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
FromIdnAddress |
Gets a new EmailAddress object which is a copy of the current object with the domain part converted from IDN format.
| |
GetAccountName |
Gets the account name of the e-mail address.
| |
GetAccountNameFromEmail |
Gets the account name of the specified e-mail address as a string.
| |
GetDomain |
Gets the domain name of the e-mail address.
| |
GetDomainFromEmail |
Gets the domain name of the specified e-mail address as a string.
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Parse |
Parses an e-mail address string and returns EmailAddress object which represents the given e-mail addresses.
| |
ToIdnAddress |
Gets a new EmailAddress object which is a copy of the current object with the domain part converted into IDN format.
| |
ToString |
Returns the e-mail address as a string.
(Overrides ObjectToString.) | |
UnescapeIdnDomain |
Converts domain part of e-mail address string from IDN format into Unicode.
|
Name | Description | |
---|---|---|
(EmailAddress to String) |
Defines an implicit conversion of an e-mail address into a string.
|
Name | Description | |
---|---|---|
AsString |
Gets or sets the full e-mail address (with optional remarks and display name) as a string.
| |
DisplayName |
Gets or sets the name which is displayed with the e-mail address.
| |
Gets or sets the actual e-mail address as a string.
| ||
Remarks |
Contains the additional information (remarks) about the e-mail address.
|
In the most cases, the developer does not need to directly create an EmailAddress object to specify e-mail addresses because the most methods and properties which deal with e-mail addresses also accept string inputs as e-mail address values.
EmailAddress class offers AsString property for this. For instance, to specify MailMessage.From as a string, set msg.From.AsString value (assuming msg is MailMessage instance).
Multiple e-mail addresses (such as the list of To, CC or BCC recipients) can be stored in EmailAddressCollection of EmailAddress objects.
If you need to deal with international e-mail addresses (IDN domains), use FromIdnAddress and ToIdnAddress methods to convert e-mail addresses between human-readable and SMTP-safe formats.
// To use the code below, import MailBee namespaces at the top of your code. using MailBee; using MailBee.Mime; // The actual code (put it into a method of your class) // Load the message from file. MailMessage msg = new MailMessage(); msg.LoadMessage(@"C:\Docs\TestMail.eml"); // For every recipient... foreach (EmailAddress adr in msg.To) { // Show full information about the recipient's e-mail address. Console.WriteLine("Recipient name: " + adr.DisplayName); Console.WriteLine("Recipient address: " + adr.Email); Console.WriteLine("Recipient info: " + adr.Remarks); Console.WriteLine("Account name: " + adr.GetAccountName()); Console.WriteLine("Domain name: " + adr.GetDomain()); }