Solved

How to validate email address format?

Posted on 2008-10-21
1
220 Views
Last Modified: 2013-12-17
Hi

I need to send email with a list. When I insert the email list, I need to validate the format of it in C# code.

while (!str.EndOfStream)
                {
                        string email = str.ReadLine().Split(new char[] { ' ,' });
                        //add to email program
}

How can I validate email address with proper format?

Thanks
0
Comment
Question by:techques
1 Comment
 
LVL 16

Accepted Solution

by:
Gyanendra Singh earned 50 total points
Comment Utility
refer this code sample
public static bool isEmail(string inputEmail)

{

    string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +

         @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + 

         @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";

   Regex re = new Regex(strRegex);

   if (re.IsMatch(inputEmail))

    return (true);

   else

    return (false);

}

Open in new window

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now