Awesome trick to validate Email Address in C# .Net (without Regular Expression)


 

Holla,

Recently I came across this fine, precise, code by Rion Williams, to check and validate an Email Address.
The code uses System.Net.Mail Namespace to check email address and returns True/False.

Very Effective and Easy!

Source Link

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

Please feel free to share your thoughts, Or similar code you’ve encountered recently in Comment section.

Advertisements

2 thoughts on “Awesome trick to validate Email Address in C# .Net (without Regular Expression)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s