1. Registered User
Join Date
Jul 2003
Posts
10

Can anybody help with some code to test an email address and see if it actually exists?

2. Grand Poobah
Join Date
May 2003
Location
Dallas
Posts
820
from within access?

3. Registered User
Join Date
Jul 2003
Posts
10
Sorry - I should have been more specific. Yes, absolutely from within Access.

Thanks

4. Registered User
Join Date
Jul 2003
Posts
38
For testing if the Mail is valid this may help:

Public Function IsValidEMail(S)
Dim Ch As String * 1, I As Long, Ats As Long, Periods As Long
Dim LeftofAt As Boolean, IsLeading As Boolean
IsValidEMail = True
If IsNull(S) Then Exit Function
IsValidEMail = False
LeftofAt = True
Periods = 0
Ats = 0
For I = 1 To Len(S)
Select Case Asc(Mid(S, I, 1))
Case Asc("@")
Ats = Ats + 1
If I = 1 Then Exit Function
If Ats > 1 Then Exit Function
LeftofAt = False
Case Asc(".")
If Not LeftofAt Then Periods = Periods + 1
If Periods > 4 Then Exit Function
If I > Len(S) - 2 Then Exit Function
Case Asc("A") To Asc("Z"), Asc("a") To Asc("z"), Asc("0") To Asc("9")
Case Asc("-")
Case Asc("_")
If IsLeading Or Not LeftofAt Then Exit Function
Case Else
Exit Function
End Select
Next
If Periods > 0 Then IsValidEMail = True
End Function

The second question was not so clear to me - you want to check if you already have it in your DB?
Then try opening a Recordset on your eMail-Table with "Select * from TABLEXY where ADRESS='newAdress'" and check if recordset.count > 0

5. Registered User
Join Date
Jul 2003
Posts
10
Thanks SubHugo - actually, your solution solves part of the problem (verifying the email address is of correct syntax). The second (and most important) part of the problem is to check whether the email address actually exists.

I am trying to avoid sending email messages to recipients that do not exist.

For example: let's assume the address username@domain.com is entered in by table.

What I need to determine is if username actually exists at domain.com without sending an email message to username.

I hope this is a bit clearer.

Thanks

6. Grand Poobah
Join Date
May 2003
Location
Dallas
Posts
820