Group:  Microsoft Access ยป microsoft.public.access.internet
Thread: Validating emails

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Validating emails
"John" <John[ at ]nospam.infovis.co.uk> 02.09.2006 01:05:26
Hi

I have this problem that client users enter emails incorrectly due to type
and either the domain name is invalid (Microsot.com instead of
Microsoft.com) or the syntax of the email (user'domain.com instead of
user[ at ]domain.com). Is there any way to ensure a) email syntax is correct and
b) reverse dns or any other check to highlight invalid domain names?

Thanks

Regards


Re: Validating emails
DS <bootybox[ at ]optonline.net> 02.09.2006 02:15:47
John wrote:

[Quoted Text]
> Hi
>
> I have this problem that client users enter emails incorrectly due to type
> and either the domain name is invalid (Microsot.com instead of
> Microsoft.com) or the syntax of the email (user'domain.com instead of
> user[ at ]domain.com). Is there any way to ensure a) email syntax is correct and
> b) reverse dns or any other check to highlight invalid domain names?
>
> Thanks
>
> Regards
>
>
Try this. I found this, never used it so I don't know if it works or not.

Function InterNetSMPT(S)
Dim HasAt, HasDomain, Host, Server
If InStr(S, "[ at ]") > 0 Then
HasAt = True
Server = Mid(S, InStr(S, "[ at ]") + 1)
If InStr(Server, ".") = 0 Then
InterNetSMPT = False
Exit Function
End If
Else
InterNetSMPT = False
Exit Function
End If
InterNetSMPT = True
End Function
RE: Validating emails
matarcallarse 03.09.2006 00:42:01
The email syntax portion is relatively easy. You'll probably get multiple
posts with various string functions for checking a valid email address. One
of the quickest ways to test strings is using Regular Expressions, long a
staple of Javascript and, for the past few years, included in VBScript as
well. RegExp is good to know (or at the very least know of), so my
recommendation would be to read up on it. You can make a reference in your
code to, "Microsoft VBScript Regular Expressions ~," and then do something
like:

Public Function CheckEmail(StringToTest) As Boolean

Dim re As New RegExp

re.Pattern = "\b[\w._%-]+[ at ][\w.-]+\.[A-Za-z]{2,4}\b"

CheckEmail=re.test(StringToTest)

Set re = Nothing

End Function

--

In the BeforeUpdate event of your field, add code to cancel the Update if
the email address is not valid:

Private Sub myField_BeforeUpdate(Cancel As Integer)

If Not CheckEmail(myField.Value) Then
MsgBox "Bad email."
Cancel = vbCancel
End If

End Sub

--

The reverse DNS piece is more complicated. You may be able to find some
classes out there that can check DNS names. Otherwise, this may be something
you need to go to the API for.

"John" wrote:

[Quoted Text]
> Hi
>
> I have this problem that client users enter emails incorrectly due to type
> and either the domain name is invalid (Microsot.com instead of
> Microsoft.com) or the syntax of the email (user'domain.com instead of
> user[ at ]domain.com). Is there any way to ensure a) email syntax is correct and
> b) reverse dns or any other check to highlight invalid domain names?
>
> Thanks
>
> Regards
>
>
>

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net