Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MX records lookup using VB.net

Posted on 2003-11-21
8
Medium Priority
?
1,868 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Loops Section Overview

927 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