I'm still getting "Failure sending mail." exception. The inner exception is "Unable to connect to the remote server" and the inner exception of that is "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond". I'm pretty sure the cause of this is not the firewall setting. Does anyone know what I can do about it? Thanks.
var mail = new MailMessage("username@gmail.com", "destination@gmail.cz")
{
Subject = "Testing subject",
Body = "Testing body"
};
try
{
var client = new SmtpClient("smtp.google.com", 465)
{
EnableSsl = true,
Credentials = new NetworkCredential("username@gmail.com", "password")
};
client.Send(mail);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…