How to resolve MX record given a domain name

  • Thread starter Thread starter Usman Jamil
  • Start date Start date
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
 
Back
Top