Alejandro Barrero wrote:I want to write code to send email without trying to specify the SMTP server.
I have tried DOS nslookup without success. On the other hand, it may be impossible and the SMTP server is not in the computer, I just don't know.
Your help will be greatly appreciated,
Alejandro Barrero
Hi,
it's simple by using MX record look up of destination SMTP server.
Download dll from.
removed, may be harmful
//Now prepare your message.
MailMessage mail = new MailMessage();
mail.To.Add("someone@somedomail.com");
mail.From = new MailAddress("tome@somedomain.com");
mail.Subject = "Send email without SMTP server";
mail.Body = "Yep, its workin!!!";
//Send message
string domain = mail.To[0].Address.Substring(mail.To[0].Address.IndexOf('@') + 1);
//To Do :need to check for MX record existance before you send. Left intentionally for you.
string mxRecord = SendSMTP.DnsLookUp.GetMXRecords(domain)[0];
SmtpClient client = new SmtpClient(mxRecord);
client.Send(mail);
Have look at
http://dvgoswami.googlepages.com/ for complete details.
Done!
Tx.
Dipak.