Check an e-mail address for validity (VB 6 and up)

Category:
Network/Internet
Type:
Snippets
Difficulty:
Beginning
Author:
Intelligent Solutions Inc.

Version Compatibility: Visual Basic 6

More information:
This function takes a string as a parameter and returns true if that string could be an e-mail address (i.e., if it is syntatically valid, if the top level domain or IP address it uses is valid, etc.).

The function makes use of the IsValidIPHost routine, which is included here and also available elsewhere on FreeVBCode.com. IsValidIPHost includes a 250-element array listing all current top-level domains. The function uses this array to determine if the supplied e-mail address's top-level domain is valid.

Note: This function will not work properly for most e-mail addresses on an Intranet, though it could be easily modified for this purpose.

VB 6 is required only because the Split function is used. If you want to use this code in an earlier version of VB, see this article from the Microsoft Knowledge Base, which shows you how to implement Split (and other VB6 specific string functions) in VB 5 and earlier.

Also see an alternative method for doing this, if you want to do it in VB5 or below and you don't want to bother with the array of top-level domains.


Instructions: Click the link below to download the code. Select 'Save' from the IE popup dialog. Once downloaded, open the .zip file from your local drive using WinZip or a comparable program to view the contents.

Download isvalidemailaddress.zip