Validate whether or not an email address is syntactically correct in C#.
/// <summary>
/// Validates an Email Address.
/// </summary>
/// <param name="emailAddress">The email address.</param>
/// <returns>True if the specified string is valid email address,
/// other wise false.</returns>
/// <remarks>
/// Will match only syntactically correct Email Addresses.
/// Dose not validate an IPv6 Domain part.
/// Validation rules and samples taken from here:
/// http://en.wikipedia.org/wiki/Email_address#Invalid_email_addresses
/// </remarks>
public static bool IsValidEmailAddress(string emailAddress)
{
return !string.IsNullOrWhiteSpace(emailAddress)
&& Regex.IsMatch(emailAddress, @"^(?:(?:[\w`~!#$%^&*\-=+;:{}'|,?\/]+(?:(?:\.(?:""(?:\\?[\w`~!#$%^&*\-=+;:{}'|,?\/\.()<>\[\] @]|\\""|\\\\)*""|[\w`~!#$%^&*\-=+;:{}'|,?\/]+))*\.[\w`~!#$%^&*\-=+;:{}'|,?\/]+)?)|(?:""(?:\\?[\w`~!#$%^&*\-=+;:{}'|,?\/\.()<>\[\] @]|\\""|\\\\)+""))@(?:[a-zA-Z\d\-]+(?:\.[a-zA-Z\d\-]+)*|\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])$");
}