try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("senttoemailaddress@gmail.com");
mail.To.Add("senttoemailaddress@gmail.com");
mail.Subject = "Test Mail";
mail.Body = "This is for testing SMTP mail from GMAIL";
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("emailaddress.test@gmail.com", "passW0ord");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
MessageBox.Show("mail Send");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
I'm trying to run the above code to automatically send emails, the code executes up until it reaches smtpServer.send(mail)
then it just stops, the email address that I use is valid and the password is valid.