NET Email Validation
BestConnectionOptions Method
Example 






KellermanSoftware.NetEmailValidation Namespace > EmailValidation Class : BestConnectionOptions Method
Returns a list of the default options excluding options that cannot be performed. The SMTP Port (normally 25) must be open to do a SMTP connect or mailbox check. Must be connected to the internet to do an MxRecord lookup. This effectively performs the greatest possible validation depending on the local machines connection capabilities.
Syntax
'Declaration
 
Public Function BestConnectionOptions() As System.Collections.Generic.List(Of ValidationOptions)
'Usage
 
Dim instance As EmailValidation
Dim value As System.Collections.Generic.List(Of ValidationOptions)
 
value = instance.BestConnectionOptions()
public System.Collections.Generic.List<ValidationOptions> BestConnectionOptions()
public function BestConnectionOptions(): System.Collections.Generic.List; 
public function BestConnectionOptions() : System.Collections.Generic.List;
public: System.Collections.Generic.List<ValidationOptions>* BestConnectionOptions(); 
public:
System.Collections.Generic.List<ValidationOptions>^ BestConnectionOptions(); 
Example
EmailValidation emailValidator = new EmailValidation(); //Trial Mode
//EmailValidation emailValidator = new EmailValidation("place user name here", "place license key here"); //License Mode
 
emailValidator.FromEmail = "someone@somewhere.com";
emailValidator.FromMailServer = "mail.somewhere.com";
 
//Connect using the best available options
List<ValidationOptions> options = emailValidator.BestConnectionOptions();
Console.WriteLine(emailValidator.BestConnectionMessage);
 
//Validate a single email with the best available options
Result myResult = emailValidator.ValidEmail("john.smith@hotmail.com", options);
 
//Print the results to the console
Console.WriteLine(myResult.UserMessage);
Console.WriteLine();
Console.WriteLine(myResult.StatusDescription);
Console.WriteLine();
Console.WriteLine(myResult.Log);
Dim emailValidator As EmailValidation = New EmailValidation() 'Trial Mode
'Dim emailValidator As EmailValidation = New EmailValidation("place user name here", "place license key here") 'License Mode
 
emailValidator.FromEmail = "someone@somewhere.com"
emailValidator.FromMailServer = "mail.somewhere.com"
 
'Connect using the best available options
Dim options As List(Of ValidationOptions) = emailValidator.BestConnectionOptions()
Console.WriteLine(emailValidator.BestConnectionMessage)
 
'Validate a single email with the best available options
Dim myResult As Result = emailValidator.ValidEmail("john.smith@hotmail.com", options)
 
'Print the results to the console
Console.WriteLine(myResult.UserMessage)
Console.WriteLine()
Console.WriteLine(myResult.StatusDescription)
Console.WriteLine()
Console.WriteLine(myResult.Log)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

EmailValidation Class
EmailValidation Members