I have been working on a project that involves sending emails, I finally got it to work but after a few days of not using my system, I tried running the code again and I was getting the "unable to connect to the remote server" error.
Please can anyone just check out the code for me, I've been on it now for more than a week.
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("***@gmail.com");
mail.To.Add("******@gmail.com");
mail.Subject = "Test";
mail.Body = ("the mdfjvnloifvhsuifv");
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("***@gmail.com", "pwd");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
Label1.Text = "MAIL SENT!!!";
}
catch (Exception ex)
{
Label1.Text = ex.ToString();
//throw;
}