Helper function that builds a full email address from a display name and an email address.
The full email address built from name and email
A full email address is similar to what is defined in the RFC2822 as mailbox, except that the display name part supports unicode characters. CreateEmailAddress allows you to create valid full email address, even if the display name contains special chars like spaces, ", \, <, >, etc. If the display name is empty or contains only spaces, the email parameter is returned.
| Exception Type | Condition |
|---|---|
| ArgumentNullException |
name is a null reference (Nothing in Visual Basic) -or- email is a null reference (Nothing in Visual Basic). |
| MailMillException | email is an invalid email address. |
This sample shows how to use the CreateEmailAddress method.
string sFullEmailAddress = Mail.CreateEmailAddress("Sales Departement", "sales@emilltest.com");
Console.WriteLine(sFullEmailAddress);
/* This code produces the following output:
"Sales Department" <sales@emilltest.com>*/
Mail Class | MailMill Namespace