PeterO.Mail.NamedAddress

## PeterO.Mail.NamedAddress

public class NamedAddress

Represents an email address and a name for that address. Can represent a group of email addresses instead.

Member Summary

### NamedAddress Constructor

public NamedAddress(
    string address);

Initializes a new instance of the PeterO.Mail.NamedAddress class. Examples:

Parameters:

.

Exceptions:

### NamedAddress Constructor

public NamedAddress(
    string displayName,
    PeterO.Mail.Address address);

Initializes a new instance of the PeterO.Mail.NamedAddress class using the given display name and email address.

Parameters:

Exceptions:

### NamedAddress Constructor

public NamedAddress(
    string displayName,
    string address);

Initializes a new instance of the PeterO.Mail.NamedAddress class using the given display name and email address.

Parameters:

Exceptions:

### NamedAddress Constructor

public NamedAddress(
    string displayName,
    string localPart,
    string domain);

Initializes a new instance of the PeterO.Mail.NamedAddress class using the given name and an email address made up of its local part and domain.

Parameters:

Exceptions:

### NamedAddress Constructor

public NamedAddress(
    string groupName,
    System.Collections.Generic.IList mailboxes);

Initializes a new instance of the PeterO.Mail.NamedAddress class. Takes a group name and several named email addresses as parameters, and forms a group with them.

Parameters:

Exceptions:

### Address

public PeterO.Mail.Address Address { get; }

Gets the email address associated with this object.

Returns:

The email address associated with this object. This value is null if this object represents a group of addresses instead.

### DisplayName

public string DisplayName { get; }

Gets the display name for this email address.

Returns:

The display name for this email address. Returns null if the display name is absent.

### GroupAddresses

public System.Collections.Generic.IList GroupAddresses { get; }

Gets a read-only list of addresses that make up the group, if this object represents a group, or an empty list otherwise.

Returns:

A list of addresses that make up the group, if this object represents a group, or an empty list otherwise.

### IsGroup

public bool IsGroup { get; }

Gets a value indicating whether this represents a group of addresses rather than a single address.

Returns:

true If this represents a group of addresses; otherwise, false .

### Name

public string Name { get; }

Gets the display name for this email address, or the email address’s value if the display name is null. Returns an empty string if the address and display name are null.

Returns:

The name for this email address.

### AddressesEqual

public bool AddressesEqual(
    PeterO.Mail.NamedAddress na);

Determines whether the email addresses stored this object are the same between this object and the given object, regardless of the display names they store. For groups, the email addresses must be equal and in the same order in both objects.

Parameters:

Return Value:

Either true or false .

### Equals

public override bool Equals(
    object obj);

Determines whether this object and another object are equal. For groups, the named addresses (display name/email address pairs) must be equal and in the same order in both objects.

Parameters:

Return Value:

true if this object and another object are equal and have the same type; otherwise, false .

### GetHashCode

public override int GetHashCode();

Calculates the hash code of this object. The exact algorithm used by this method is not guaranteed to be the same between versions of this library, and no application or process IDs are used in the hash code calculation.

Return Value:

A 32-bit hash code.

### ParseAddresses

public static System.Collections.Generic.IList ParseAddresses(
    string addressValue);

Generates a list of NamedAddress objects from a comma-separated list of addresses. Each address must follow the syntax accepted by the one-argument constructor of NamedAddress.

Parameters:

Return Value:

A list of addresses generated from the addressValue parameter.

Exceptions:

### ToDisplayString

public static string ToDisplayString(
    System.Collections.Generic.IList addresses);

Generates a string containing the display names and email addresses of the given named-address objects, separated by commas. The generated string is intended to be displayed to end users, and is not intended to be parsed by computer programs.

Parameters:

Return Value:

A string containing the display names and email addresses of the given named-address objects, separated by commas.

Exceptions:

### ToDisplayString

public string ToDisplayString();

Converts this named-address object to a text string intended for display to end users. The returned string is not intended to be parsed by computer programs.

Return Value:

A text string of this named-address object, intended for display to end-users.

### ToDisplayStringShort

public static string ToDisplayStringShort(
    System.Collections.Generic.IList addresses);

Generates a string containing the display names of the given named-address objects, separated by commas. The generated string is intended to be displayed to end users, and is not intended to be parsed by computer programs. If a named address has no display name, its email address is used as the display name.

Parameters:

Return Value:

A string containing the display names of the given named-address objects, separated by commas.

Exceptions:

### ToString

public override string ToString();

Converts this object to a text string. This will generally be the form of this NamedAddress object as it could appear in a “To” header field.

Return Value:

A string representation of this object.

Back to MailLib start page.