Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

MX records lookup using VB.net

Posted on 2003-11-21
8
1,708 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 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