Good this is my code:
MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress("[email protected]"));
msg.From = new MailAddress("[email protected]");
msg.Subject = "Asunto(Correo Prueba)";
msg.Body = "Contenido Prueba";
msg.IsBodyHtml = false;
msg.Priority = MailPriority.Normal;
SmtpClient smtpClient = new SmtpClient();
smtpClient.Host = "smtp.gmail.com";
smtpClient.Port = 465;
smtpClient.EnableSsl = true;
smtpClient.Credentials = new NetworkCredential("[email protected]", "xxxxxx");
ServicePointManager.ServerCertificateValidationCallback =
(s, certificate, chai, sslPolicyErrors) => true;
//Envio del correo
try
{
//Envio del correo
smtpClient.Send(msg);
return "OK";
}
catch (SmtpException ex)
{
Console.WriteLine(ex.Message);
return ex.Message;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return ex.Message;
}
finally
{
msg.Dispose();
smtpClient.Dispose();
}'
You do not send me the mail and I just get a message saying Error when sending mail, I put the email to allow access from less secure applications and also activate the imap that I may be missing?