Querys MX records of specified domain from DNS server.
[VisualĀ Basic]
Public Sub QueryServers( _
domain As String _
) As SmtpServer()
Public Sub QueryServers( _
domain As String _
dnsServerIP As String
) As SmtpServer()
[C#]
public SmtpServer[] QueryServers(
string domain
);
public SmtpServer[] QueryServers(
string domain,
string dnsServerIP
);
[C++]
public: SmtpServer* __gc [] QueryServers(
String* domain
);
public: SmtpServer* __gc [] QueryServers(
String* domain,
String* dnsServerIP
);
[JScript]
public function QueryServers(
domain : String
) : SmtpServer[];
public function QueryServers(
domain : String
dnsServerIP : String
) : SmtpServer[];
Parameters
Remarks
Example
[C#] To get the full samples of EASendMail, please refer to Samples section.
[C#]
using EASendMail;
public void Send()
{
try
{
SmtpServer [] servers = DnsQueryEx.QueryServers( "to@adminsystem.com" );
//query MX record (smtp server address) for to@adminsystem.com
//try to send email with every smtp server queryed until the email was sent.
for( int i = 0; i < servers.Length; i++ )
{
SmtpServer oServer = servers[i];
SmtpClient oSmtp = new SmtpClient();
SmtpMail oMail = new SmtpMail("TryIt");
oMail.From = new MailAddress( "from@adminsystem.com" );
oMail.To.Add(new MailAddress("to@adminsystem.com"));
oMail.Subject = "test subject";
oMail.TextBody = "test body";
try
{
oSmtp.SendMail( oServer, oMail );
//succeeded, break.
break;
}
catch( Exception exp )
{
MessageBox.Show( exp.Message );
}
}
}
catch( Exception ep )
{
MessageBox.Show( ep.Message );
}
}