Solved

Validate domain name in an emali account

Posted on 2010-08-13
13
375 Views
Last Modified: 2012-06-21
Hi: We want to be able to validate the domain name of an email account when user input this value in our webpage, in short terms we want to accomplish the following scenerio:
user type->: myaccount@anygivendomainname.com
our routine checks for anygivendomainname.com and check if it really exists, if not then we can inform customer and she/he can double check the field value
Thanks
0
Comment
Question by:rubensc
  • 5
  • 4
  • 2
  • +1
13 Comments
 
LVL 5

Expert Comment

by:JayFromPep
ID: 33429715
There are a ton of answers for this.

You can do some pretty cool stuff with System.net.dns that will allow you to check with some dns servers to make sure the domain is a valid domain.

I.E.....

IPHostEntry hostInfo = Dns.GetHostByName("www.contoso.com");

You can also use 3rd party stuff.

here is a link to a topic that touches on just this.

http://www.velocityreviews.com/forums/t81340-dns-lookup-from-net-validate-email-address-domain.html
0
 
LVL 11

Expert Comment

by:ladarling
ID: 33431966
This is an example of splitting the email address apart and checking it with a host lookup:
(The split will put place the username in index 0 and the domain in index 1 of a string array)
 

Dim anEmailAddress As String = "somebody@somewhere.com"
        Dim mailParts() As String = Split(anEmailAddress, "@")
        Dim hostIP As Net.IPHostEntry = Net.Dns.GetHostEntry(mailParts(1))
        If Not IsNothing(hostIP) Then
            MsgBox("DNS found the domain name: " & hostIP.HostName)
        Else
            MsgBox("Not a valid domain:" & hostIP.HostName)

        End If

Open in new window

0
 
LVL 5

Expert Comment

by:JayFromPep
ID: 33432111
Sorry, i put it in c#.

But ladarling is right.  Just a simple split and dns check will cover you on it.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:DanielBlais
ID: 33446255
In VB6 application, I don't know how to do this.  You can use the NSLOOKUP command line tool.

Call this line and get back the result in .txt file.
nslookup.exe -type=MX somewhere.com > nslookup.txt

Open in new window

0
 

Author Comment

by:rubensc
ID: 33446873
DanielBlais: Thanks for the comment, but I don't plan to use a Shell to execute the command.
0
 
LVL 2

Accepted Solution

by:
DanielBlais earned 125 total points
ID: 33447000
0
 
LVL 11

Expert Comment

by:ladarling
ID: 33447048
Did my previous code not work for you?
0
 
LVL 2

Expert Comment

by:DanielBlais
ID: 33447131
I just noticed your question is on both classic VB and VB.NET.

Can you tell us which language you want.
0
 

Author Comment

by:rubensc
ID: 33457348
I can do both, no problem
Thanks
0
 
LVL 2

Expert Comment

by:DanielBlais
ID: 33457887
So, is there any good solution for you?
0
 

Author Comment

by:rubensc
ID: 33457939
I will prefer ASP.NET, the thing with the cmdshell (nslookup) it's external and asyncronous, we are testing the Net.Dns.GetHostEntry stuff, any other idea?
Regards
0
 
LVL 2

Expert Comment

by:DanielBlais
ID: 33457977
I agree the .NET solution is the best one.
0
 

Author Closing Comment

by:rubensc
ID: 33719159
I resolve it
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS SQL 2008 and stored prodcures and dates 5 25
Fastest way to find and count same items VB6 16 43
MS SQL + date 6 41
VB.Net - BackgroundWorker running multiple 5 45
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question