Dart.PowerTCP.EmailValidation Namespace > Validator Class > Validate Method : Validate(String) Method |
Validates email addresses in a blocking fashion.
[Visual Basic]
Overloads Public Function Validate( _
ByVal emailAddress As String _
) As ValidationState
[C#]
public ValidationState Validate(
string emailAddress
);
[C++]
public: ValidationState* Validate(
string* emailAddress
)
[C++/CLI]
public:
ValidationState^ Validate(
String^ emailAddress
)
A ValidationState including the address, the requested level, the progression level, and possibly, an exception.
Exception | Description |
---|---|
ValidationException | Indicates a negative validation response. |
Use this overload for validating a single email address.
The following example demonstrates the blocking validation of an email address.
[Visual Basic]
Private Function doValidation(ByVal emailAddress As String) 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 and return the result
Dim result As ValidationState = Validator1.Validate(emailAddress)
Dim description As String = "The validation of " + result.EmailAddress + " proceeded to the "
description += result.Progress.ToString() + " level. "
If (result.Exception Is Nothing) Then
description += "The validation was successful."
Else
description += "The following exception occurred: " + result.Exception.ToString()
End If
Return description
End Function
[C#]
private string 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 and return the result
ValidationState result = validator1.Validate(emailAddress);
string description = "The validation of "
+ result.EmailAddress + " proceeded to the ";
description += result.Progress.ToString() + " level. ";
description += (result.Exception == null)
? "The validation was successful."
: "The following exception occurred: " + result.Exception.ToString();
return description;
}
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.