EmailAddressValidatorVerify Method (String) |
Namespace: MailBee.AddressCheck
Exception | Condition |
---|---|
MailBeeInvalidArgumentException | emails is a null reference (Nothing in Visual Basic) or DnsServers collection is empty. |
MailBeeUserAbortException | The user code has aborted the component with Abort method. |
To analyze the results, subscribe to Verified event. To implement blacklist or whitelist, subscribe to Verifying event.
For more info and tutorials, refer to Getting started with Address Validator guide.
using System; using MailBee; using MailBee.AddressCheck; class Program { // This method will be executed for each e-mail address in the bulk, // whenever it gets verified, with either positive or negative result. private static void valid_Verified(object sender, VerifiedEventArgs e) { Console.WriteLine("*** Verified ***"); Console.WriteLine("Email: " + e.Email); Console.WriteLine("Result: " + e.Result.ToString()); if (e.Reason != null) { Console.WriteLine("Reason: " + e.Reason.Message); } Console.WriteLine(); } static void Main(string[] args) { EmailAddressValidator valid = new EmailAddressValidator("MN110-0123456789ABCDEF-0123"); // To perform DNS MX lookup queries, we need some DNS servers for that. valid.DnsServers.Autodetect(); // Logging into a file is not required for the component to work // but helpful for debugging and understanding things under the hood. valid.Log.Enabled = true; valid.Log.Filename = @"C:\Temp\log.txt"; valid.Log.Clear(); // Subscribe to event. valid.Verified += new VerifiedEventHandler(valid_Verified); // Populate an array with some e-mails. You can also use DataTable as a source. string[] emails = new string[] { "jdoe@company.com", "bob@example.com", "alice@domain.com" }; // Run the verification in single-threaded mode. valid.Verify(emails); } }