Free Support Forum - aspose.com

Where is Aspose.Network.Mail.DnsMailClient?

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??

Hi Jaime,


DnsClient is the part of Aspose.Network.Dns namespace. The specified example uses both Aspose.Email and Aspose.Network for .NET components to demonstrate the use of DnsClient. You can download the latest version of Aspose.Network for .NET v6.9.0 from the free utilities page.

Hope this helps.

hi, Babar


the Aspose.Network for .NET can not be download anymore, than i want to know how to send mail using dns in current?

thanks

Hi Pyntia,


You may please download the latest version of Aspose.Email for .NET 5.4.0 to achieve all the functionality provided by Aspsoe.Network for .NET as it is discontinued and is no more supported. Please visit Send Mail using DNS to have a sample code for this purpose.