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.asp

<%@ EnableSessionState=false Language="VBScript" %>
<%
option explicit
Response.Buffer = true

dim sEmail
sEmail = request( "email" )
%>
<!-- #include file="HexGadgets.inc.vbs.asp" -->
<!-- #include file="HexValidEmail.inc.vbs.asp" -->
<html><head><title>Simple Email Validation</title></head>
<body>

<form method="POST" action="<%= Request( "SCRIPT_NAME" ) %>">
<P>Email address<br>
<INPUT name="email" value="<%= sEmail %>">&nbsp; <INPUT type="submit" value="Submit" name="submit"></P>
</form>
<%
if "" <> sEmail then
	dim oVE, iRating, sOutput
	
	'// Create object
	set oVE = Server.CreateObject( "HexValidEmail.Connection" )
	
	'// Identify yourself for SMTP (use your own information here)
	'// See http://www.hexillion.com/docs/guides/HexValidEmail/concepts/polite_usage.htm
	oVE.FromDomain = "hexillion.com"                '// The domain name of your machine
	oVE.FromEmail = "HexValidEmail@hexillion.com"   '// Email address of technical contact person
	
	'// Set timeouts (optional)
	oVE.Timeouts(hexVeTimeoutDnsTotal).Value = 4000
	oVE.Timeouts(hexVeTimeoutSmtpTotal).Value = 10000
	
	'// Do the validation to SMTP level
	iRating = oVE.Validate( sEmail, hexVeLevelSmtp )
	
	'// If the address is definitely bad...
	if hexVeLevelBad = iRating then
		
		'// Display the reason why
		sOutput = "Bad address: " & GetVeErrorString( oVE.Error )
	
	'// If validation didn't reach intended level...	
	elseif iRating < hexVeLevelSmtp then
	
		'// Say why
		sOutput = "No problems were found with the address, " & _
		          "but the validation failed at level " & (iRating + 1) & " " & _
		          "with the following error: " & GetVeErrorString( oVE.Error )
		          
	else
		'// No problems encountered
		sOutput = "No problems were found with the address. That does not guarantee it is good."
	
	end if		
	
	Response.Write "<p>" & sOutput & "</p>"
	Set oVE = Nothing
end if
%>
</body></html>