Provides options for selecting methods of automatic detection of the DNS servers registered in the system.
This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
If multiple methods are specified, they are tried in the order their values increase until at least one DNS server definition is found.
Note To search WMI database (Wmi option), the application must have appropriate permissions to use System.Management.dll (which encapsulates Management namespace). For instance, web applications configured to run on "High" trust level have no permissions to access this assembly. In this case, Autodetect method will not find any DNS server records in WMI database. Changing trust level to "Full" eliminates the problem.
This sample populates the collection of DNS servers with the servers defined in the config files (such as app.config, web.config, or machine.config). If it does not find any DNS server definitions in the config files, then Windows registry is searched.
[C#] // To use the code below, import MailBee namespaces at the top of your code using MailBee; using MailBee.SmtpMail; using MailBee.DnsMX; // The actual code Smtp smtp = new Smtp(); smtp.DnsServers.Autodetect(DnsAutodetectOptions.ConfigFiles | DnsAutodetectOptions.Registry); // Example of XML config file settings which must be placed into <appSettings> section of the file // (<appSettings> can also appear as <applicationSettings> in .NET 2.0). // It defines 2 DNS servers with top (0) priority and 1 backup server with lower (1) priority // (for 192.168.0.2 server, the priority is not specified and thus defaults to the top priority): <add key="MailBee.DnsMX.DnsServerCollection" value="192.168.0.1,0;192.168.0.2;192.168.0.100,1"/>
[Visual Basic] ' To use the code below, import MailBee namespaces at the top of your code Imports MailBee Imports MailBee.SmtpMail Imports MailBee.DnsMX ' The actual code Dim smtp As New Smtp smtp.DnsServers.Autodetect(DnsAutodetectOptions.ConfigFiles Or DnsAutodetectOptions.Registry) ' Example of XML config file settings which must be placed into <appSettings> section of the file ' (<appSettings> can also appear as <applicationSettings> in .NET 2.0). ' It defines 2 DNS servers with top (0) priority and 1 backup server with lower (1) priority ' (for 192.168.0.2 server, the priority is not specified and thus defaults to the top priority): <add key="MailBee.DnsMX.DnsServerCollection" value="192.168.0.1,0;192.168.0.2;192.168.0.100,1"/>
| Member Name | Description | Value |
|---|---|---|
| None | Do nothing. | 0 |
| ConfigFiles | Search DNS server definitions in "MailBee.DnsMX.DnsServerCollection" key of "appSettings" section of the config files (such as app.config, web.config, or machine.config), where the key value contains ";"-separated list of DNS servers in "IP Address,Priority" format. If the priority is omitted, the top (0) priority will be assigned to the DNS server. | 1 |
| Registry | Search DNS server definitions in Windows registry. | 2 |
| Wmi | Search DNS server definitions in WMI database. | 4 |
| RootServers | Populate DNS servers collection with the Internet root DNS servers: A.ROOT-SERVERS.NET, B.ROOT-SERVERS.NET, C.ROOT-SERVERS.NET, D.ROOT-SERVERS.NET. This method is not recommended since the root servers report no DNS records for most hosts in the Internet. | 8 |
Namespace: MailBee.DnsMX
Assembly: MailBee.NET (in MailBee.NET.dll)
MailBee.DnsMX Namespace | Smtp