Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I have to send an email via hotmail in c# wpf application.I am using internet at college which uses a proxy server .i am using the following code

C#
  MailMessage message = new MailMessage();
            message.From = new MailAddress(textBox4.Text);
            message.Subject = textBox2.Text;
            message.Body = textBox3.Text;
           

            SmtpClient client = new SmtpClient();
            client.Credentials = new NetworkCredential(textBox4.Text, textBox5.Text);
            client.Host = "smtp-mail.outlook.com";
            client.Port = 25;
            client.EnableSsl = true;
            
            try
            {
                client.Send(message);
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message.ToString());
             Application.Exit();
            }
            finally
            {
                MessageBox.Show("Email Sent", "Success");
}


but i always get System.Net.WebException remote name could not be resolved ..can any one help me????
Posted
Updated 20-Apr-15 4:26am
v2
Comments
Andy Lanng 20-Apr-15 10:29am    
Please remember that you can wrap code in 'pre' tags. These options can be found at the top of the textarea.
When you say that "you have to", doesn't that imply that this is a personal assignment? If so then you will find little chance of outside help here :/
Richard Deeming 20-Apr-15 10:59am    
The code you've posted doesn't add any recipients to the message (message.To, message.CC or message.Bcc). Did you forget to post that part of the code, or have you forgotten to write it?

The error message sounds like a DNS issue. Try starting a command-prompt and running:
nslookup smtp-mail.outlook.com
Member 10699633 20-Apr-15 12:11pm    
well i have written message.To=textbox1.text but forgot to write in question and when i executed nslookup smtp-mail.outlook.com it gives

dns request time out.
time out was 2 seconds.
dns request time out.
time out was 2 seconds.
Richard Deeming 20-Apr-15 12:13pm    
The DNS timeout is the most likely cause of the problem. You'll need to talk to the sysadmin at your college to find out why DNS isn't working.
Joan Magnet 21-Apr-15 6:40am    
Try using IP instead of server name. 65.55.163.152

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900