Advanced email validation component for Microsoft .NET
var engine = new VerificationEngine();
// ...
var result = engine.Run("seti@home@example.com",
VerificationLevel.Syntax).Result;
if (result.SyntaxFailureIndex.HasValue)
{
// Will output: InvalidCharacterInSequence
Console.WriteLine(result.Status);
// Will output: 9
Console.WriteLine(result.SyntaxFailureIndex);
}
"the quick brown fox"@example.com
"seti\@home"@example.com
var engine = new VerificationEngine();
// Turn quoted strings (and pairs) support off
engine.DefaultSettings.AllowQuotedStrings = false;
george@bücher.ch(note the diaeresis in the domain part)
асиич@мировая-почта.ru(this email address uses a cyrillic encoding)
var engine = new VerificationEngine();
// ...
var result = engine.Run("george@bücher.ch",
VerificationLevel.Syntax).Result;
if (result.HasInternationalDomainName)
{
Console.WriteLine("Non-ASCII domain name detected.");
// Will output xn--bcher-kva.ch
Console.WriteLine(result.AsciiEmailAddressDomainPart);
}
if (result.HasInternationalMailboxName)
{
Console.WriteLine("Non-ASCII mailbox name detected.");
}
var engine = new VerificationEngine();
// Turn internationalized domain names (IDN) support off
engine.DefaultSettings.AllowInternationalDomainNames = false;
// Turn non-ASCII local parts support off
engine.DefaultSettings.AllowInternationalMailboxNames = false;
john(smith)@(my (domain))example.com(tld)
var engine = new VerificationEngine();
// ...
var result = engine.Run("john(smith)@(my (domain))example.com(tld)",
VerificationLevel.Syntax).Result;
// Show the email address without comments
// Will output: john@example.com
Console.WriteLine(result.EmailAddress);
// Show each extracted comment
// Will output: smith, my domain and tld
foreach (var comment in result.Comments)
{
Console.WriteLine(comment);
}
var engine = new VerificationEngine();
// Turn comments support off
engine.DefaultSettings.AllowComments = false;
test@[173.194.69.27]
var engine = new VerificationEngine();
// Turn domain literals support off
engine.DefaultSettings.AllowDomainLiterals = false;