Search: in  

zip DNS MX Lookup Class

Downloads: 161 File Size: 21.8kB
Posted By: RobK410 Views: 2,295
Date Added: 09-07-2007

The .NET library provides a simple way to lookup DNS records through the System.Net.Dns class but stops there. There are times when developing an e-mail application or server where we may need to determine a domain's mail exchanger host. There is a unique DNS record type for these records but there is no direct interface written in .NET for them... So here is a class called LookupMX that will call the dnsapi.dll allowing us to lookup and get all MX server records for a specified domain. This class is included in a simple Console project that demonstrates how easy it is to use this class.

   1:  
   2: namespace MXLookup
   3: {
   4:     class Program
   5:     {
   6:         static void Main(string[] args)
   7:         {
   8:             if (args.Length > 0)
   9:             {
  10:                 LookupMX lookup = new LookupMX(args[0]);
  11:                 Console.WriteLine("MX Records for: " + args[0]);
  12:  
  13:                 foreach (MXRecord mx in lookup.MXRecords)
  14:                 {
  15:                     Console.WriteLine(mx.ToString());
  16:                 }
  17:             }
  18:             else
  19:                 Console.WriteLine("USAGE: MXLookup.exe [domain.name]");
  20:             
  21:         }
  22:         
  23:     }
  24: }
Share this post: E-mail DNS+MX+Lookup+Class | Submit DNS+MX+Lookup+Class to Technorati | Submit DNS+MX+Lookup+Class to del.icio.us | Submit DNS+MX+Lookup+Class to digg.com | Submit DNS+MX+Lookup+Class to reddit.com | Submit DNS+MX+Lookup+Class to DotNetKicks | Add DNS+MX+Lookup+Class to Live Bookmarks

Filed under: , , ,

Comments

No comments exist for this file.
Copyright © 2007, RobKennedy.com.
I reserve the right to beat yo arse if you steal sh!t.
Shat out at you via the CommunityServer.org Engine