Created
May 25, 2018 10:54
-
-
Save johnw86/db4b1afdab22c6b7577fc7cd40136de1 to your computer and use it in GitHub Desktop.
Email validator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Net.Mail; | |
namespace EmailValidator | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
var emails = File.ReadAllLines("emails.txt"); | |
for (var i = 0; i < emails.Length; i++) | |
{ | |
var email = emails[i]; | |
try | |
{ | |
new MailAddress(email); | |
} | |
catch (FormatException) | |
{ | |
Console.WriteLine($"Invalid email address: {email}, line number: {i}"); | |
} | |
catch (Exception e) | |
{ | |
Console.WriteLine(e); | |
throw; | |
} | |
} | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment