NET Email Validation
ValidEmailAsync(String,String,List<ValidationOptions>) Method
Example 






KellermanSoftware.NetEmailValidation Namespace > EmailValidation Class > ValidEmailAsync Method : ValidEmailAsync(String,String,List<ValidationOptions>) Method
Validate a single email address asynchronously using the passed options
Syntax
'Declaration
 
Public Overloads Sub ValidEmailAsync( _
   ByVal contactId As System.String, _
   ByVal emailAddress As System.String, _
   ByVal options As System.Collections.Generic.List(Of ValidationOptions) _
) 
'Usage
 
Dim instance As EmailValidation
Dim contactId As System.String
Dim emailAddress As System.String
Dim options As System.Collections.Generic.List(Of ValidationOptions)
 
instance.ValidEmailAsync(contactId, emailAddress, options)
public void ValidEmailAsync( 
   System.string contactId,
   System.string emailAddress,
   System.Collections.Generic.List<ValidationOptions> options
)
public procedure ValidEmailAsync( 
    contactId: System.String;
    emailAddress: System.String;
    options: System.Collections.Generic.List
); 
public function ValidEmailAsync( 
   contactId : System.String,
   emailAddress : System.String,
   options : System.Collections.Generic.List
);
public: void ValidEmailAsync( 
   System.string* contactId,
   System.string* emailAddress,
   System.Collections.Generic.List<ValidationOptions>* options
) 
public:
void ValidEmailAsync( 
   System.String^ contactId,
   System.String^ emailAddress,
   System.Collections.Generic.List<ValidationOptions>^ options
) 

Parameters

contactId
emailAddress
options
Example
public void 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";
 
    List<ValidationOptions> options = emailValidator.BestConnectionOptions();
 
    //Attach Events                
    emailValidator.ResponseReceivedEvent += new EmailValidation.ResponseReceivedEventHandler(ResponseReceivedEvent);
 
    emailValidator.ValidEmailAsync("1", "johnsmith@hotmail.com", options);
 
    //Wait until finished
    while (emailValidator.IsBusy)
    {
        System.Threading.Thread.Sleep(100);
    }
 
    //Remove the event connections
    emailValidator.ResponseReceivedEvent -= new EmailValidation.ResponseReceivedEventHandler(ResponseReceivedEvent);
}
 
public void ResponseReceivedEvent(object sender, Result result)
{
    if (result.IsValid)
    {
        //Do something
    }
    else
    {
        //Do something else
    }
 
    Console.WriteLine(result.Log);
}
Public Sub Example()
    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"
 
    Dim options As List(Of ValidationOptions) = emailValidator.BestConnectionOptions()
 
    'Attach Events                
    AddHandler emailValidator.ResponseReceivedEvent, AddressOf ResponseReceivedEvent
 
    emailValidator.ValidEmailAsync("1", "johnsmith@hotmail.com", options)
 
    'Wait until finished
    Do While emailValidator.IsBusy
        System.Threading.Thread.Sleep(100)
    Loop
 
    'Remove the event connections
    RemoveHandler emailValidator.ResponseReceivedEvent, AddressOf ResponseReceivedEvent
End Sub
 
Public Sub ResponseReceivedEvent(ByVal sender As Object, ByVal result As Result)
    If result.IsValid Then
        'Do something
    Else
        'Do something else
    End If
 
    Console.WriteLine(result.Log)
End Sub
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
Overload List