SeekfordSolutions.DNSMXWizard Class Library

DNSClient Class

DNSClient Members

DNSLookup provides the ability to lookup the mail exchange resource records for a domain

        [C#]
        public class DNSClient : Object
      

Example

The following code example queries a DNS server and obtains the MX records for a domain

using System; 
using SeekfordSolutions.DNSMXWizard;

public class MyClass {

    public static void Main() 
		{
		DNSClient myDNSClient = new DNSClient("Serial Number");
		ArrayList myDNSServers = new ArrayList();
		myDNSServers = myDNSClient.GetSystemDNSServers();
		myDNSClient.SetServers(myDNSServers);
		Console.WriteLine("Performing MX Lookup");
		MailExchangeData MXData;
		ArrayList myMXList;
		try
		{			
			myMXList = myDNSClient.MailExchangeLookup("www.SeekfordSolutions.com");
			Console.WriteLine("MX Lookup results:\r\nServer\tPreference\r\n");
			for(int iX=0; iX < myMXList.Count;iX++)
			{
				MXData = (MailExchangeData)myMXList[iX];
				Console.WriteLine(MXData.Server.ToString() + "\t" + MXData.Priority.ToString() + "\r\n"); 
			}
		}
		catch(Exception err)
		{
			Console.WriteLine(err.Message.ToString());				
		}
		
    }
}

/*
	
This code produces the following output:
Performing MX Lookup
MX Lookup results:
Server	Preference
64.89.8.154	10

*/

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family

See Also

DNSMXWizard Namespace