Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MX records lookup using VB.net

Posted on 2003-11-21
8
Medium Priority
?
1,836 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
[X]
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
  • 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
How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

 
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 1000 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

Not sure which OpenStack Certification to get?

So you’ve realized you might want to get certified in OpenStack, but you’re not sure what the benefits might be or even which one you should take. You know there are several certification courses you can choose from, but how do you know which one is right for you?

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

715 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