Imports ComponentPro.Net

Partial Public Class _Default
	Inherits System.Web.UI.Page
	Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

	End Sub
	Protected Sub btnValidate_Click(ByVal sender As Object, ByVal e As EventArgs)
		If Page.IsValid Then
			Try
				' Create a new instance of the EmailValidator class.
				Dim sfbEmailValidator As New EmailValidator()

				' If the From domain text box value is not empty.
				If txtFromDomain.Text.Length > 0 Then
					sfbEmailValidator.SmtpHeloDomain = txtFromDomain.Text
				End If

				' If the SmtpPort text box value is not empty.
				If txtSmtpPort.Text.Length > 0 Then
					sfbEmailValidator.SmtpPort = Integer.Parse(txtSmtpPort.Text)
				End If

				' If the SmtpMail text box value is not empty.
				If txtSmtpMail.Text.Length > 0 Then
					sfbEmailValidator.SmtpFromEmail = txtSmtpMail.Text
				End If

				' If the DnsServer text box value is not empty.
				If txtDnsServer.Text.Length > 0 Then
					sfbEmailValidator.DnsServers.Add(txtDnsServer.Text)
				End If

				' Parse the validation level.
				sfbEmailValidator.ValidationLevel = CType(Integer.Parse(ddlValidationLevel.SelectedValue), ValidationLevel)

				' Validate the provided email.
				sfbEmailValidator.Validate(txtEmail.Text)

				' Show result.
				lblResult.Text = sfbEmailValidator.SmtpTranscript.Replace(vbCrLf, "<br>")
			Catch exc As Exception
				lblResult.Text = "An exception occurred: " & exc.Message
			End Try
		End If
	End Sub
End Class