I tried to send mail using Windows application in C#. I got code as below and tried but it is not working
It giving following error:
Unable to connect the remove server
Code:
MailAddress sendd = new MailAddress("xxxxxx@gmail.com","Sethu",Encoding.UTF8);
MailAddress receivee = new MailAddress("xxxxxx@yahoo.com");
MailMessage mail = new MailMessage(sendd, receivee);
SmtpClient client = new SmtpClient();
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("xxxxxx@gmail.com", "yyyyyyy");
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);
Anyone help to find out what mistake i did?