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("[email protected]","Sethu",Encoding.UTF8);
MailAddress receivee = new MailAddress("[email protected]");
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("[email protected]", "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?