See Also

Validator Class  | Validator Members  | Overload List

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista

Language

Visual Basic

C#

C++

C++/CLI

Show All

emailAddresses
The list of email addresses to validate.
See Also Languages PowerTCP Email Validation for .NET

Validate(IList) Method

Dart.PowerTCP.EmailValidation Namespace > Validator Class > Validate Method : Validate(IList) Method

Validates email addresses in a blocking fashion.

[Visual Basic]
Overloads Public Function Validate( _    ByVal emailAddresses As IList _ ) As ValidationState()
[C#]
public ValidationState[] Validate(    IList emailAddresses );
[C++]
public: ValidationState*[]* Validate(    IList* emailAddresses )
[C++/CLI]
public: array<ValidationState^>^ Validate(    IList^ emailAddresses )

Parameters

emailAddresses
The list of email addresses to validate.

Return Type

An array of ValidationStates corresponding to the supplied list of email addresses.

Exceptions

ExceptionDescription
ValidationExceptionIndicates a negative validation response.

Remarks

Use this overload when validating a list of email addresses. This overload has advantages over the single address overload. First, it makes use of TestAccount when this property is set. Second, it persists connections to mail servers hosting multiple addresses in the list.

Example

The following example demonstrates the blocking validation of an email address list.

[Visual Basic] 

Private Function doValidation() As String()
    'Add "Imports Dart.PowerTCP.EmailValidation" at the top
    'Add "Imports System.Collections.Specialized" at the top
    'Add "Imports System.IO" at the top

    'Validation settings
    Validator1.ValidationLevel = ValidationLevel.SmtpRecipient 'final level
    Validator1.BlackList = getList(Application.StartupPath + "\blacklist.txt")
    Validator1.WhiteList = getList(Application.StartupPath + "\whitelist.txt")
    Validator1.DomainCacheTimeout = 300 '300 second (5 minute) domain cache
    Validator1.Smtp.TestAccount = "qwerty1298mnbvc" 'skip known "false positives"

    '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 results
    Dim results As ValidationState() = Validator1.Validate(getList(Application.StartupPath + "\myList.txt"))
    Dim descriptions(results.Length - 1) As String
    Dim i As Integer
    For i = 0 To results.Length - 1
        descriptions(i) = "The validation of " + results(i).EmailAddress + " proceeded to the "
        descriptions(i) += results(i).Progress.ToString() + " level. "
        If (results(i).Exception Is Nothing) Then
            descriptions(i) += "The validation was successful."
        Else
            descriptions(i) += "The following exception occurred: " + results(i).Exception.ToString()
        End If
    Next
    Return descriptions
End Function

Private Function getList(ByVal filename As String) As StringCollection
    'Read a list from a file
    Dim list As StringCollection = New StringCollection
    Dim reader As StreamReader = New StreamReader(filename)
    While (reader.Peek() <= 0)
        list.Add(reader.ReadLine())
    End While
    reader.Close()
    Return list
End Function

[C#] 

private string[] doValidation()
{
   
//Add "using Dart.PowerTCP.EmailValidation;" at the top
   
//Add "using System.Collections.Specialized;" at the top
   
//Add "using System.IO;" at the top

   
//Validation settings
   
validator1.ValidationLevel = ValidationLevel.SmtpRecipient; //final level
   
validator1.BlackList = getList(Application.StartupPath + "\\blacklist.txt");
   validator1.WhiteList = getList(Application.StartupPath +
"\\whitelist.txt");
   validator1.DomainCacheTimeout = 300;
'300 second (5 minute) domain cache
   
validator1.Smtp.TestAccount = "qwerty1298mnbvc"; //skip known "false positives"

   
//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 results
   
ValidationState[] results = validator1.Validate(getList(Application.StartupPath + "\\myList.txt"));
   
string[] descriptions = new string[results.Length];
   
for (int i=0; i&lt;results.Length; i++)
   {
       descriptions[i] =
"The validation of " + results[i].EmailAddress + " proceeded to the ";
       descriptions[i] += results[i].Progress.ToString() +
" level. ";
       descriptions[i] += (results[i].Exception ==
null)
           ?
"The validation was successful."
           
: "The following exception occurred: " + results[i].Exception.ToString();
   }
   
return descriptions;
}

private StringCollection getList(string filename)
{
   
//Read a list from a file
   
StringCollection list = new StringCollection();
   StreamReader reader =
new StreamReader(filename);
   
while (reader.Peek() &gt;= 0)
       list.Add(reader.ReadLine());
   reader.Close();
   
return list;
}
                

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista

See Also

Validator Class  | Validator Members  | Overload List


Send comments on this topic.

Documentation version 1.0.3.0.

© 2008 Dart Communications.  All rights reserved.