Solved

MX records lookup using VB.net

Posted on 2003-11-21
8
1,730 Views
Last Modified: 2012-06-27
Hello,

Can anyone please tell me the easiest way to perform MX record Lookup in VB.net ? Is there any specific procedures to do this or do i need to create a component ? can dnsapi.dll be used to do this..

If possible, i would like to see the source code for such Mail-Exchange server lookups in VB.net.

Thank you.

Dheenu
0
Comment
Question by:deenadayalan
  • 5
  • 3
8 Comments
 
LVL 6

Expert Comment

by:zrh
ID: 9801366
I can't give you source code right now, but take a look at the Dns Class, I believe it's under System.Net, it might help you.
ZRH
0
 
LVL 2

Expert Comment

by:dheenu27
ID: 9804314
Hi,
I had gone through MSDN documentation on DNS and related subjects. But it happened to say that "There is currently no way to programmatically query the DNS database other than gethostbyname(). It is currently not possible to do things such as programmatically query the DNS for an MX record".

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndns/html/dnsnt4.asp

I think programmatic-querying a DNS for obtaining MX RR's is not that easy as i'm thinking right now. It would be great if you can give me some tips on how to start with the program using VB.net.

I tried out searching the web for same, but i found some commercial components like ANSMTP and DNSMXQuery which are way too expensive. Is there any simple logic behind this to obtain those records ?

Thanks.
Dheenu
0
 
LVL 6

Expert Comment

by:zrh
ID: 9808263
You can try this component, its free.
http://www.internext.co.za/stefan/aspmx/

If your using visual studio .net you can very easily import it by going to add reference -> Com Component. Then browse for the dll, then the ResolverClass is in the ASPMX namespace. (see site for api reference)

Hope that helps,
ZRH
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 2

Expert Comment

by:dheenu27
ID: 9813949
Hi,
That information was helpful indeed. But can you tell me if i can use the same ASP component in my VB.net application ?

I tried compiling the same code by making changes for my VB.net application. But ended up with errors, and nothing happened.

Is there any other way to do that? That is setting up the same ASP component for my VB.net application. Does it work ?

Thanks.
0
 
LVL 6

Accepted Solution

by:
zrh earned 250 total points
ID: 9814226
Yeah it works for Windows Forms applications also,
For example try this code: (assuming you added the reference like aforementioned)

Imports ASPMX
...
            Dim resolver As New ResolverClass
            Dim errorMsg As String
            Dim hostsStr As String = "MX Entries" & vbCrLf
            resolver.DNSServer = "cumulus.home"
            resolver.TimeOutValue = 30
            resolver.Domain = "microsoft.com"

            errorMsg = resolver.Resolve()
            For i As Int32 = 0 To resolver.MXCount
                hostsStr &= "Host:" & resolver.MX(i) & " Priority:" & resolver.MXPriority(i).ToString() & vbCrLf
            Next
            MessageBox.Show(hostsStr)

Note: to use this component you will have to register it:
regsvr32 <path_to_dll>/aspmx.dll

Hope that helps,
ZRH
0
 
LVL 6

Expert Comment

by:zrh
ID: 9814236
Note, change the DNSServer to your dns server...
ZRH
0
 
LVL 2

Expert Comment

by:dheenu27
ID: 9814433
Thanks a lot ZRH, this really worked.
I appreciate your patience in this regard.

Dheenu
0
 
LVL 6

Expert Comment

by:zrh
ID: 9815361
No problem, glad to help.
ZRH
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

713 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