ASP.NET - The remote name could not be resolved: ''

Asked By aileni giri on 27-Mar-12 02:30 AM
i got an error while sending email
 the error is as  follows 
   The remotre server could not be resolved: ''

the  following is the code.

string @from = ConfigurationManager.AppSettings["email"].ToString();
    string pwd = ConfigurationManager.AppSettings["pwd"].ToString();
    //SmtpClient smtpClient = new SmtpClient();
    MailMessage message = new MailMessage();
    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
    string m1 = pocmail;
      mail.From = new MailAddress(@from, @from, System.Text.Encoding.UTF8);
      mail.Subject = "JobOrder Details";
      mail.SubjectEncoding = System.Text.Encoding.UTF8;
      mail.Body = "Recruitment Drive:"
      mail.BodyEncoding = System.Text.Encoding.UTF8;
      mail.IsBodyHtml = true;
      mail.Priority = MailPriority.High;
      SmtpClient client = new SmtpClient();
      client.Host = "";
      client.Port = 25;
     // client.UseDefaultCredentials = true;
     // client.Credentials = new System.Net.NetworkCredential(@from, pwd);
     //client.EnableSsl = true;

please  anybody help me.
dipa ahuja replied to aileni giri on 27-Mar-12 02:41 AM
Step 1 : Add this in Web.config
<network host=""
Step 2 : Mail Sending Code
using System.Net.Mail;
using System.Net;
protected void btnSent_Click(object sender, EventArgs e)
  string toEmailAddress = "";
  string GmailId = "";
  string bodyMsg = "helo its testing mail";
  string subject = "testing mail";
  MailMessage mail = new MailMessage();
  mail.From = new MailAddress(GmailId);
  mail.Subject = subject;
  mail.Body = bodyMsg;
  mail.IsBodyHtml = true;
    SmtpClient smtp = new SmtpClient();
  smtp.EnableSsl = true;
Somesh Yadav replied to aileni giri on 27-Mar-12 02:45 AM
In my opinion, this error message is quite self-explanatory: You cannot create a connection to the SMTP server you have specified.
There is probably nothing wrong with your code as it is.
You need to check why you can't access the SMTP server.
For starters, try pinging from the machine your application is running on.


If it is having issues resolving the server name, then that is likely a DNS issue on the server. CS simply goes to the connect to the given hostname, and the system will automatically try to resolve the hostname into an IP using the DNS servers the server is configured to use.
Take not of the email server setting in CS, then log into the server, open a command prompt, and type "nslookup". if it can't resolve it, then you might want to check the DNS settings for the domain, or the DNS servers your server is set up to use.

BTW: Before that, just check it's not the firewall creating the issue. Port being used is open and permissions given.
aileni giri replied to dipa ahuja on 27-Mar-12 03:10 AM
i did it ,but i am getting same error.
kalpana aparnathi replied to aileni giri on 27-Mar-12 03:11 PM

This Error  means the computer asked for the IP-address of '' at your configurated DNS server and this returned it couldn't find an IP-address for ''.

please check for this:

Is '' a valid address?

Is there a DNS server configured at the computer and has this DNS server a valid DNS entry for ''?


aileni giri replied to kalpana aparnathi on 28-Mar-12 06:23 AM
thanks alot ya.