Built-in method to validate email address in C#

Published on February 10, 2016 by Senthil Kumar

Filed under C#

Last modified February 9, 2016

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 8197 times

Are you looking for a built-in method in C# which lets you validate email address. If yes , you can use the EmailAddressAttribute class that is defined in the System.ComponentModel.DataAnnotations namespace to do it.

How to validate email address in C# using EmailAddressAttribute class ?

Below is a sample code snippet demonstrating the usage of the EmailAddressAttribute class to validate the email address in C#.

using System;
using System.ComponentModel.DataAnnotations;

namespace ACCode
    class Program
        static void Main(string[] args)
            EmailAddressAttribute validator = new EmailAddressAttribute();
            var result1 = validator.IsValid("test@gmail");
            var result2 = validator.IsValid("test@gmail.com");

1 Comment

  1. Ginktage – Community Blog Posts – February 10 , 2016 | Ginktage
    February 10, 2016 - 9:28 pm

Leave a Comment


You might be Interested in these Posts

Mandrill - Email Infrastructure Service

Mandrill is an email infrastructure service that started as an idea in 2010. That idea became realit...

How to Deserialize JSON data in Windows Phone 8 app ?

To Deserialize JSON data in Windows Phone 8 , the developers can utilize the json.NET . How to Dese...

How to Programatically Send Email with attachments in Windows Phone 8.1 using C# ?

Below is a sample code snippet that demonstrates how to send email with attachments programmatically...