Filter out bad email addresses

  • Thread starter Thread starter Chris W.
  • Start date Start date
C

Chris W.

Does anyone have existing code that filters out bad email
addresses. I can write my own routine, but i need to know
what characters are not allowed on the Left and right of
the @ sign.
 
Not sure about the exact regular expression here but something like
this should work.

Tim.


Function EmailOK(sIn As String) As Boolean

Static regEx As Object

bValid = False
If regEx Is Nothing Then
Set regEx = CreateObject("vbscript.regexp")
regEx.Pattern =
"^[A-Z][\w\.-]*[A-Z0-9]@[A-Z0-9][\w\.-]*[A-Z0-9]\.[A-Z][A-Z\.]*[A-Z]$"
regEx.Global = True
regEx.IgnoreCase = True
End If

EmailOK = regEx.test(sIn)

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top