i want sent an email(gmail) using my application, but i have an error, my code is syntactically correct. Here is my code
public void send(string body , string objet)
try
{
NetworkCredential log = new NetworkCredential();
SmtpClient smtp = new SmtpClient("smtp.gmail.com");
MailMessage msg = new MailMessage();
msg.To.Add("you@gmail.com");
msg.Body = body;
msg.From = new MailAddress("me@gmail.com");
msg.Subject = objet;
smtp.EnableSsl = true;
smtp.Port = 465;
smtp.Credential= new NetworkCredential("me@gmail", "passwdgmail");
smtp.Send(msg);
MessageBox.Show("succés");
}
catch (Exception ex)
{MessageBox.Show(ex.StackTrace);}
}
}
when i did the ex.message in the try..catch: the error message is: sending failure some mail when I did ex.StackTrace, the error is in smtp.Send(msg);