Solved

MX records lookup using VB.net

Posted on 2003-11-21
8
1,638 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now