Class that represents an RFC 2822 mailbox.
For a list of all members of this type, see Mailbox Members.
System.Object
Node
FieldBody
Address
Mailbox
RFC 2822 defines a mailbox as an entity that can be the recipient of a message. A mailbox is more specific than an address, which may be either a mailbox or a group. An RFC 2822 mailbox contains a display name, a local part, an optional route, and a domain. For example, in the mailbox
Joe Schmoe <jschmoe@example.com>
"Joe Schmoe" is the display name, "jschmoe" is the local part, and "example.com" is the domain. The optional route is rarely seen in current usage, and is deprecated according to RFC 2822.
Note: The terms are not as precise as they should be. Technically, we should make a distinction between a mailbox and a mailbox name. We don't make that distinction because RFC 2822 doesn't make that distinction.
In Hunny MIME.NET, an RFC 2822 mailbox is represented by a
Mailbox object. Mailbox is a subclass of Address, which reflects the fact that a mailbox is also an
address. A Mailbox contains strings for the display name, local
part, route, and domain of a mailbox.
Mailbox has properties for getting or setting the strings it
contains.
In the document tree representation of a message, a Mailbox
object may be only a leaf node, having a parent node but no child
nodes. Its parent node should be a Field object
or an AddressList object.
Usage
To use Mailbox to parse a mailbox string, create an instance
using the constructor that takes a ByteString
argument. Call the Parse() method to parse the
string representation. Then get the DisplayName,
LocalPart, and Domain
properties to get the parsed substrings.
To use Mailbox to generate a mailbox string, create an
instance using the default constructor. Set the LocalPart, Domain, and DisplayName properties to set the local part, domain, and
display name, respectively. Call Assemble() to
update the string representation. Then, get the Node.String property to get the string
representation.
Mailbox Formats
The format of mailboxes found in Internet mail varies. The following shows some alternative formats:
In example (2), the quotation marks are required because the display name contains the characters "." and ",". In example (3), there is no display name. The format in example (4) is the traditional format for Usenet articles. Examples (5) and (6) use the encoding specified in RFC 2047. The encoding is not needed in these examples, because all the characters are 7-bit US-ASCII characters. However, the encoding is required if the display name contains characters not in the 7-bit US-ASCII character set. Example (5) uses a modified form of the quoted-printable transfer encoding (RFC 2045) to encode the display name "Joe H. Schmoe, Jr.", which uses the ISO 8859-1 character set. Example (6) uses the base64 transfer encoding (RFC 2045) to encode only the second "word" of the display name "Joe Schmoe", which uses the UTF-8 encoding of Unicode.
Hunny MIME.NET correctly parses mailboxes in all the formats shown above. When mailboxes are assembled (that is, generated), one of the formats in examples (1), (2), or (5) is selected in that order.
Namespace: Hunny.Mime
Assembly: Hunny.Mime (in Hunny.Mime.dll)
Mailbox Members | Hunny.Mime Namespace