Skip to main content

C# helper method to determine if a email address is valid.

public static bool IsValidEmail(string email)
{
    if (string.IsNullOrWhiteSpace(email))
    {
        return false;
    }

    try
    {
        return string.Equals(
            new System.Net.Mail.MailAddress(email).Address,
            email, StringComparison.InvariantCultureIgnoreCase);
    }
    catch (FormatException)
    {
        return false;
    }
}