Note: This is not the complete source code--just the main source file.
You can download the full source (with include files) from our sample code archive by clicking on the diskette icons.

SimpleEmailValidation.vb.aspx

<%@ Page Language="VB" EnableSessionState="false" EnableViewState="false" %>
<%@ Import namespace="Hexillion.HexValidEmail.Interop" %>

<script runat="server">

'// SimpleEmailValidation sample in VB.NET
'// version 2003-12-12
'// 
'// Demonstrates basic email address validation with 
'// HexValidEmail COM using .NET interop.
'//
'// HexGadget components required:
'// HexValidEmail COM
'// (For more info, go to http://www.Hexillion.com/hg/ )
'//
'// History:
'// 2003-12-12  Created
'//
'// Copyright 2003 Hexillion Technologies. All rights reserved.
'// 
'// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
'// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
'// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND/OR
'// FITNESS FOR A PARTICULAR PURPOSE.

Sub Page_Load()

	If IsPostBack Then
		'// Create an instance of the Connection class
		Dim hve As New Connection()

		'// Identify yourself for SMTP (use your own information here)
		'// See http://www.hexillion.com/docs/guides/HexValidEmail/concepts/polite_usage.htm
		hve.FromDomain = "hexillion.com"               '// The domain name of your machine
		hve.FromEmail = "HexValidEmail@hexillion.com"  '// Email address of technical contact person

		'// Set timeouts (optional)
		hve.Timeouts.Item(HexValidEmailTimeout.hexVeTimeoutDnsTotal).Value = 4000
		hve.Timeouts.Item(HexValidEmailTimeout.hexVeTimeoutSmtpTotal).Value = 10000

		'// Do the validation to SMTP level
		Dim rating As HexValidEmailLevel
		rating = CType(hve.Validate(email.Text, HexValidEmailLevel.hexVeLevelSmtp), HexValidEmailLevel)
      
		'// If the address is definitely bad...
		If HexValidEmailLevel.hexVeLevelBad = rating Then
         
			'// Display the reason why
			output.Text = "Bad address: " + CType(hve.Error, HexValidEmailErrors).ToString()

		'// If validation didn't reach intended level...	
		ElseIf rating < HexValidEmailLevel.hexVeLevelSmtp Then
            
			'// Say why
			output.Text = "No problems were found with the address, " & _
			              "but the validation failed at level " & _
			              (CInt(rating) + 1).ToString() & _
			              " with the following error: " & _
			              CType(hve.Error, HexValidEmailErrors).ToString()
         
		Else
			'// No problems encountered
			output.Text = "No problems were found with the address, though that does not guarantee it is good."
		End If
	End If
End Sub 'Page_Load
</script>
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<title>Simple Email Validation</title>
	</head>
	<body>
		<form id="MainForm" runat="server">
			<p>Email address<br />
			<asp:textbox id="email" runat="server" /> &nbsp;
			<asp:button id="submit" text="Submit" runat="server" />
			</p>
			<asp:label id="output" runat="server" />
		</form>
	</body>
</html>