my code:
private void button1_Click(object sender, EventArgs e)
{
try
{
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("mymail@gmail.com", "mypassword");
client.EnableSsl = true;
MailMessage mail = new MailMessage();
mail.From = new MailAddress("mymail@gmail.com", "SMTP Test");
mail.To.Add(new MailAddress("mymail@gmail.com"));
mail.Subject = "Subject test";
mail.Body = "Body test";
client.Send(mail);
MessageBox.Show("mail send.");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
I get this error:
I cant upload images yet so i use puush.
http://puu.sh/fpAnF/d4372b0b55.png
Error a bit translated:
Error when sending e-mail. system.net.mail.smtpexception: error when sending e-mail. ---> system.net.webexception: can't connect to the external server ---> system.net.sockets.sochetexception: can't connect because the goalcomputer (dont know the exact translation of that) the connection actively has refused.
can somobody please help me?