How to resolve MX record given a domain name

U

Usman Jamil

Hi

I'm having problem resolving DNS records of a domain using C#. What I want
to do is an exact replica of this command

nslookup.exe -type=MX [domainname] [dns-ip]

i.e I need to resolve the MX record of a domain name using a certain Dns
server. I tried calling unmanaged code as given below and it succeeds well,
but I can't mention, which DNS server to use while resolving the MX record
of that domain. Is there any such possibility using C#.

[DllImport("dnsapi", EntryPoint="DnsQuery_W", CharSet=CharSet.Unicode,
SetLastError=true, ExactSpelling=true)]
private static extern int
DnsQuery([MarshalAs(UnmanagedType.VBByRefStr)]ref string pszName, QueryTypes
wType, QueryOptions options, int aipServers, ref IntPtr ppQueryResults, int
pReserved);


Regards

Usman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top