NET Email Validation
ValidEmailAsync(String) Method
Example 






KellermanSoftware.NetEmailValidation Namespace > EmailValidation Class > ValidEmailAsync Method : ValidEmailAsync(String) Method
Validate an email asynchronously using the default options
Syntax
'Declaration
 
Public Overloads Sub ValidEmailAsync( _
   ByVal emailAddress As System.String _
) 
'Usage
 
Dim instance As EmailValidation
Dim emailAddress As System.String
 
instance.ValidEmailAsync(emailAddress)
public void ValidEmailAsync( 
   System.string emailAddress
)
public procedure ValidEmailAsync( 
    emailAddress: System.String
); 
public function ValidEmailAsync( 
   emailAddress : System.String
);
public: void ValidEmailAsync( 
   System.string* emailAddress
) 
public:
void ValidEmailAsync( 
   System.String^ emailAddress
) 

Parameters

emailAddress
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";
 
    //Attach Events                
    emailValidator.ResponseReceivedEvent += new EmailValidation.ResponseReceivedEventHandler(ResponseReceivedEvent);
 
    emailValidator.ValidEmailAsync("johnsmith@hotmail.com");
 
    //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"
 
    'Attach Events                
    AddHandler emailValidator.ResponseReceivedEvent, AddressOf ResponseReceivedEvent
    
    emailValidator.ValidEmailAsync("johnsmith@hotmail.com")
    
    '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