What about this Function! ....Regards Bob
Public Function IsValidEmail(emailAddress As String) As Boolean
'Check if e-mail address is a valid address
' Requires "tblCountryCodes", "tblDomain Suffix"
Dim Pos As Long, iveLth As Integer, I As Integer, isOkMail As Boolean, _
iveStr As String, chrOK(66) As String, chrFound As Boolean, iveIdStr As
String, _
iveDomStr As String, idTmp As Variant, iveSfx As String, strChrDesc
Dim ivePmt As String, iveBtns As Integer, iveTitle As String, iveResp As
Integer
iveTitle = "e-Mail address verification"
iveBtns = vbExclamation
isOkMail = True
iveStr = Trim(emailAddress)
iveLth = Len(iveStr)
'Checking for illegal characters
'Permitted 45-46 (-.), 48-57 (digits); 64 @, 65-90 (Ucase alpha); 97-122
(Lcase alpha)
' 95 (_)
chrOK(1) = Chr(45)
chrOK(2) = Chr(46)
For I = 48 To 57
chrOK(I - 45) = Chr(I)
Next I
For I = 64 To 90
chrOK(I - 51) = Chr(I)
Next I
chrOK(40) = Chr(95)
For I = 97 To 122
chrOK(I - 56) = Chr(I)
Next I
For Pos = 1 To iveLth
chrFound = False
For I = 1 To 66
If Mid(iveStr, Pos, 1) = chrOK(I) Then
chrFound = True
Exit For
End If
Next I
If Not chrFound Then
strChrDesc = Mid(iveStr, Pos, 1)
Select Case strChrDesc
Case " "
strChrDesc = "(space)"
Case Chr(34)
strChrDesc = "(qoutation mark)"
Case "'"
strChrDesc = "(Apostrophe)"
Case Else
strChrDesc = "'" & strChrDesc & "'"
End Select
IsValidEmail = False
MsgBox "Ilegal character " & strChrDesc & " Found in Position "
& Pos _
& Chr(13) & "Adresss: " & iveStr & " Character: " & strChrDesc
_
& " = Chr(" & Asc(Mid(iveStr, Pos, 1)) & ") ", iveBtns,
iveTitle
Exit Function
End If
Next Pos
' Test for @
Pos = InStr(1, iveStr, "@")
If Pos = 1 Or Pos > iveLth - 4 Then
IsValidEmail = False
MsgBox "@ charcter is in wrong position", iveBtns, iveTitle
Exit Function
ElseIf Pos = 0 Or IsNull(Pos) Then
IsValidEmail = False
MsgBox "No @ character found", iveBtns, iveTitle
Exit Function
End If
iveIdStr = Left(iveStr, Pos - 1)
iveDomStr = Right(iveStr, Len(iveStr) - Pos)
If Len(iveDomStr) > 67 Then
MsgBox "Domain name is too long - maximum is 67 characters ",
iveBtns, iveTitle
IsValidEmail = False
Exit Function
End If
Pos = InStr(1, iveDomStr, "@")
If Pos > 0 Then
IsValidEmail = False
MsgBox "@ character found more then one time", iveBtns, iveTitle
Exit Function
End If
'checking for last dot
Pos = InStrRev(iveDomStr, ".")
'If Pos < Len(iveDomStr) - 3 Or Pos > Len(iveDomStr) - 2 Then
If Pos < Len(iveDomStr) - 4 Or Pos > Len(iveDomStr) - 2 Then
IsValidEmail = False
MsgBox "Last dot (.) is in wrong position or missing", iveBtns,
iveTitle
Exit Function
End If
'check for 2 consec dots
Pos = InStr(1, iveStr, "..")
If Pos > 0 Then
IsValidEmail = False
MsgBox "2 consecutive dots (..) found", iveBtns, iveTitle
Exit Function
End If
'Test for valid domain suffix
Pos = InStrRev(iveDomStr, ".")
If Pos = Len(iveDomStr) - 2 Then
iveSfx = Right(iveDomStr, 2)
idTmp = DLookup("[Country_ID]", "tblCountryCodes", "[Country
Code]='" & iveSfx & "'")
If IsNull(idTmp) Then
iveBtns = vbOKCancel + vbQuestion
ivePmt = "Domain suffix '." & iveSfx & "' not found " &
Chr(13) & Chr(13) _
& "Use '" & iveSfx & "' anyway? "
iveResp = MsgBox(ivePmt, iveBtns, iveTitle)
If iveResp = vbCancel Then
IsValidEmail = False
Exit Function
End If
End If
Else
iveSfx = Right(iveDomStr, Len(iveDomStr) - Pos)
idTmp = DLookup("[DomSuffix_ID]", "tblDomain Suffix", "[Suffix]='" &
iveSfx & "'")
If IsNull(idTmp) Then
iveBtns = vbExclamation
ivePmt = "Invalid domain suffix '." & iveSfx & "'"
MsgBox ivePmt, iveBtns, iveTitle
IsValidEmail = False
Exit Function
End If
End If
IsValidEmail = True
End Function