I wrote this code and It's not working
try
{
MailMessage mailMessage = new MailMessage();
mailMessage.To.Add("XXXXXXX@gmail.com");
mailMessage.From = new MailAddress("XXXXXXX@gmail.com");
mailMessage.Subject = "ASP.NET e-mail test";
mailMessage.Body = "Hello world,\n\nThis is an ASP.NET test e-mail!";
SmtpClient smtpClient = new SmtpClient("smtp.gmail.com");
smtpClient.Send(mailMessage);
Response.Write("E-mail sent!");
}
catch (Exception ex)
{
Response.Write("Could not send the e-mail - error: " + ex.Message);
}
I Took this code from asp.net tutorials. It is not working for me.
I get an error:
Failed to send e-mail
Appreciate any help