How to set up Email Address Verification using Visual Basic

Email Address Verification within .NET


private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(doValidation(“yourAddress@gmail.com”));
}

private string doValidation(string emailAddress)
{
    //Validate to the ultimate level.
validator1.ValidationLevel = ValidationLevel.SmtpRecipient;

    //Raise the progress event for every validation step.
validator1.VerboseProgress = true;

    //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 = “from@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;
description += ” proceeded to the “; + result.Progress.ToString() + ” level. “;
description += (result.Exception == null)
“The validation was successful.”
“The following exception occurred: “ + result.Exception.ToString();
    return description;
}

private void validator1_Progress(object sender, ProgressEventArgs e)
{
    //Record validation progress to a log.
    if (e.ValidationState.Exception == null)
textLog.AppendText(e.ValidationState.EmailAddress + ” OK: “ +
e.ValidationState.Progress.ToString() + Environment.NewLine);
    else
textLog.AppendText(e.ValidationState.EmailAddress + ” ERROR: “ +
e.ValidationState.Exception.Message + Environment.NewLine);
}

Advertisements

About berrymanchris

I recently graduated from University of Wisconsin - Whitewater and I work as a Senior Analyst at PANGEA Studios at the University in Whitewater, WI.

Posted on July 18, 2013, in Blog. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: