I read the "Send Mail using DNS" article here:
http://www.aspose.com/documentation/.net-components/aspose.network-for-.net/send-mail-using-dns.html
But I cannot find a DnsMailClient class in the Aspose.Network.Mail namespace anywhere. What am I missing?
Thanks,
Rob
Hi Rob,
Thank you for inquiry.
Please use the below sample code to send the email using DNS. The DnsMailClient has been removed from Aspose.Network, it used the similar logic as below.
private static void DnsSendMessage(MailMessage msg)
{
// Get all the recipients in to, cc and bcc in one collection
MailAddressCollection addresses = new MailAddressCollection();
foreach (MailAddress to in msg.To)
{
addresses.Add(to);
}
foreach (MailAddress cc in msg.CC)
{
addresses.Add(cc);
}
foreach (MailAddress bcc in msg.Bcc)
{
addresses.Add(bcc);
}
// send mail using DNS to each address
foreach (MailAddress addr in addresses)
{
//Find mail exchange servers with the help of DnsClient
DnsClient dnsClient = new DnsClient();
Question mxQuestion = new Question(addr.Host, QueryType.MX);
if (dnsClient.Resolve(mxQuestion))
{
// try to send a message
foreach (ResourceRecord record in dnsClient.ReceivedMessage.Answers)
{
MXResourceRecord cnRecord = record as MXResourceRecord;
if (cnRecord != null)
{
try
{
// Send message
SmtpClient client = new SmtpClient();
client.AuthenticationMethod = SmtpAuthentication.None;
client.Host = cnRecord.ExchangeName;
client.Port = 25;
client.Send(msg);
Console.WriteLine("Mail sent to " + addr.Address);
}
catch (SmtpException e)
{
Console.WriteLine(cnRecord.ExchangeName + ": " + e.Message + Environment.NewLine);
continue;
}
}
}
}
}
}
And where is the DnsClient in the Aspose.Email??