Dart.PowerTCP.EmailValidation Namespace > Validator Class > BeginValidate Method : BeginValidate(String,Object) Method |
Validates email addresses in a non-blocking fashion.
[Visual Basic]
Overloads Public Function BeginValidate( _
ByVal emailAddress As String, _
ByVal state As Object _
) As IAsyncResult
[C#]
public IAsyncResult BeginValidate(
string emailAddress,
object state
);
[C++]
public: IAsyncResult* BeginValidate(
string* emailAddress,
Object* state
)
[C++/CLI]
public:
IAsyncResult^ BeginValidate(
String^ emailAddress,
Object^ state
)
Exception | Description |
---|---|
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler. |
Use this overload when validation a single email address.
The EndValidate event will fire when BeginValidate has completed.
The following example demonstrates the non-blocking validation of an email address.
[Visual Basic]
Private Sub doValidation(ByVal emailAddress As String)
'Add "Imports Dart.PowerTCP.EmailValidation" at the top
'Validate to the final level
Validator1.ValidationLevel = ValidationLevel.SmtpRecipient
'DNS settings
Validator1.Dns.RotateServers = False 'always start with first server
Validator1.Dns.Retries = 2 'try up to 3 times
Validator1.Dns.Timeout = 5000 '5 seconds
'SMTP settings
Validator1.Smtp.MailFrom = "myAccount@myDomain.com" 'required
Validator1.Smtp.ConnectTimeout = 40000 '40 seconds
Validator1.Smtp.ReceiveTimeout = 40000 '40 seconds
'Validate. EndValidate event will fire with result
Validator1.BeginValidate(emailAddress, Nothing)
End Sub
Private Sub Validator1_EndValidate(ByVal sender As Object, ByVal e As ValidateEventArgs)_
Handles Validator1.EndValidate
'Examine the result. For single email validation, examine the first item in the Result array
Dim result As String = "The validation of " + e.Result(0).EmailAddress + " proceeded to the "
result += e.Result(0).Progress.ToString() + " level. "
If (e.Result(0).Exception Is Nothing) Then
result += "The validation was successful."
Else
result += "The following exception occurred: " + e.Result(0).Exception.ToString()
End If
'Pass the result to a displaying function
display(result)
End Sub
[C#]
private void doValidation(string
emailAddress)
{
//Add "using Dart.PowerTCP.EmailValidation;" at the top
//Validate to the final level
validator1.ValidationLevel = ValidationLevel.SmtpRecipient;
//DNS settings
validator1.Dns.RotateServers = false; //always start with first server
validator1.Dns.Retries = 2; //try up to 3 times
validator1.Dns.Timeout = 5000; //5 seconds
//SMTP settings
validator1.Smtp.MailFrom = "myAccount@myDomain.com"; //required
validator1.Smtp.ConnectTimeout = 40000; //40 seconds
validator1.Smtp.ReceiveTimeout = 40000; //40 seconds
//Validate. EndValidate event will fire with result
validator1.BeginValidate(emailAddress, null);
}
private void validator1_EndValidate(object
sender, ValidateEventArgs e)
{
//Examine the result. For single email validation, examine the first item in the Result array
string result = "The validation of " + e.Result[0].EmailAddress + " proceeded to the ";
result += e.Result[0].Progress.ToString() + " level. ";
result += (e.Result[0].Exception == null)
? "The validation was successful."
: "The following exception occurred: " + e.Result[0].Exception.ToString();
//Pass the result to a displaying function
display(result);
}
Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista
Validator Class | Validator Members | Overload List
Send comments on this topic.
Documentation version 1.0.3.0.
© 2008 Dart Communications. All rights reserved.