Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2003
    Posts
    10

    Question Unanswered: Verify email addresses

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

    I want to avoid sending email newsletters to inaccurate email addresses.

    Many thanks in advance

  2. #2
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    from within access?

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

    Thanks

  4. #4
    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
    IsLeading = 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
    IsLeading = True
    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")
    IsLeading = False
    Case Asc("-")
    If IsLeading Then Exit Function
    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. #5
    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.

    The address has correct syntax.

    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. #6
    Join Date
    May 2003
    Location
    Dallas
    Posts
    817
    Provided Answers: 5
    I knew you wanteed more of a verification of existence code than validation of syntax.

    I have seen code for this in ASP but never out of access/VBA - let me check my asp code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •