Validate email list through Regex


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Regex matchRegex = new Regex(@"[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-\.]+\.[a-zA-Z]{2,5}");
  2. MatchCollection matches =
  3. matchRegex.Matches("zako@hotmail.com, weko2@yhaoo.com,kareem@gmail.com");
  4. if ( matches.Count > 0)
  5. {
  6. for ( int i = 0; i <>
  7. {
  8. // You can process the email matched
  9. // for example you can check if it's a real email address or not.
  10. // by pinging the mail provider.
  11. ProcessEmailAddress(matches[i].Value);
  12. }
  13. }

URL: http://cairocafe.blogspot.com/2006/05/regex-validating-csv-email-addresses.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.