Community discussion forum

Validate email addresses

This is a comment thread discussing Validate email addresses
  • 9 years ago

    This thread is for discussions of Validate email addresses.

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 5 years ago

    What about poor old us in the UK?
    Checking the domain names isn't perhaps completely advisable unless you have a complete list since this code would also invalidate French addresses (.fr), German (.de) addresses and the people from all those other countries who don't chose a .com address.

  • 5 years ago

    I think the best way to do it, rather than a hardcoded list of TLDs (which would have to include every country's two-letter ISO code) would be to simply perform an MX record lookup against your local nameserver for the domain in question. If it resolves, you at least you know you have a valid domain; if it doesn't, then you don't. That way you don't have addresses like "asdk@dsfljkalasdk.com" pass through as valid.

  • 5 years ago

    so mutch work and you only need same lines to do the same thing
    dont forget add the reference microsoft vbscript expressions
    it goes to emails and urls and all kind of things






    Dim myReg As RegExp
    Private Sub txtemail_Validate(Cancel As Boolean)
    If X = 2 Then
    Cancel = Not myReg.Test(txtemail)
    End If
    End Sub


    Private Sub Form_Load()
    Set myReg = New RegExp
    myReg.IgnoreCase = True
    myReg.Pattern = "^[\w-.]+@\w+.\w+$"
    end sub

  • 4 years ago

    Very true indeed I just wanted to make one snippet that works even if you're not online at the moment.
    Otherwise you can try adding a ping of the domain too.


    Personally I don't like probing MX records of DNS. I've seen some codes do that and they become a little bit to much spam friendly in the end.


    I updated the code to include 245 known ISO country codes.
    We'll just have to wait until James gets in to re-activate the code.

Post a reply

Enter your message below

Sign in or Join us (it's free).