ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

IsValidEmail

Validate Email ID in C#

Source

public static bool IsValidEmail(this string email)
{
    try
    {
        var addr = new System.Net.Mail.MailAddress(email);
        return true;
    }
    catch
    {
        return false;
    }
}

Example

string ToAddress = "check@test.com";
ToAddress.IsValidEmail()

Author: Hitendra

Submitted on: 31 jul. 2013

Language: C#

Type: System.Net.Mail

Views: 12285