Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

email address

Status
Not open for further replies.

wirehead

MIS
Nov 27, 2001
9
0
0
US
I would like to know if there is a way to validate an email address. I just want to check the construct name@my.com, not whether it's an actual email (if that makes sense?). Is there a way to capture the error message if the construct is not right (name@my,com), when trying to email using outlook thru Access 2000, and continue with the rest of the records.

thanks,
wirehead
 
I'm sure there's code written to do this, but it shouldn't be that hard to come up with on your own...check out the InStr command. You can use that to check that there's an @, that there's a ., and that the @ comes before the last ..

Here's a _very_ simplistic version:
Function IsEdress(strEdress As String) As Boolean
Dim intLoc As Integer
intLoc = InStr(1, strEdress, "@")
If intLoc > 0 Then
IsEdress = (InStr(intLoc, strEdress, ".") > 0)
End If
End Function

One of the ways it fails if if you have something like this:
"jerem.y@asd.fco@m"
That doesn't look too likely, but it would be easy enough to end up with "jer@blah.comjer@blad.com".

I'm sure there are other ways it falls down, as I only spent a few seconds putting it together (I'm a quick typist).
Jeremy
Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top