Procedure Name | Type | Description |
(Declarations) | Declarations | Declarations and private variables for the modEmailValidation module. |
IsEmailOK | Procedure | Determine if one Email address is okay. Email can be simply "name@fmsinc.com" or include a friendly name" |
GetEmailParts | Procedure | Get the three component parts of an email ( |
CheckEmailName | Procedure | Verify the name portion of an email address (text before the @ symbol). |
CheckDomain | Procedure | Verify the domain portion of an email address (text after the @ symbol). Based on this required format: No spaces, must have a "." but can't start or end with it. Only letters, numbers, ".", and "-" allowed. |
IsMultipleEmailOK | Procedure | Validate a list of email addresses against standard email formats -- does not determine if the email address is a valid recipient or domain. |
SeparateMultipleEmails | Procedure | Separate an email string with multiple email addresses into an array of individual email addresses. Emails may be separated by ; , chr(10) or chr(13). |
' Example of modEmailValidation ' ' To use this example, create a new module and paste this code into it. ' Then run the procedure by putting the cursor in the procedure and pressing: ' F5 to run it, or ' F8 to step through it line-by-line (see the Debug menu for more options) Private Sub Example_modEmailValidation() ' Comments: Examples of modEmailValidation to verify an email address or set of email addresses conforms to standards in VBA and VB6. ' See the Immediate Window for the results. Dim strEmail As String Dim astrEmail() As String Dim strBadEmail As String Dim strFriendly As String Dim strName As String Dim strDomain As String Dim i As Integer strEmail = InputBox("Enter one or more email addresses, separated by ; or ,", , "support@fmsinc.com, fms@fmsinc.com") ' Demonstrate IsMultipleEmailOK If Not IsMultipleEmailOK(strEmail, True, strBadEmail) Then MsgBox "No email addresses entered or bad email address(es) found: " & strBadEmail Else MsgBox "All email addresses OK" ' Demonstrate SeparateMultipleEmails Debug.Print SeparateMultipleEmails(strEmail, astrEmail) & " email(s) read into array." For i = 1 To UBound(astrEmail) Debug.Print "---------------------------" Debug.Print astrEmail(i) ' Demonstrate IsEmailOK Debug.Print "IsEmailOK: " & IsEmailOK(astrEmail(i)) ' Demonstrate GetEmailParts If GetEmailParts(astrEmail(i), strFriendly, strName, strDomain) Then Debug.Print " Friendly Name: " & strFriendly Debug.Print " Name: " & strName Debug.Print " Domain: " & strDomain ' Demonstrate CheckEmailName Debug.Print "CheckEmailName: " & CheckEmailName(strName) ' Demonstrate CheckDomain Debug.Print "CheckDomain: " & CheckDomain(strDomain) End If Next i End If End Sub
The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.
Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!
Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!
"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."
Van T. Dinh, Microsoft MVP