Please Do not mark this as duplicate. I can find so may questions related to this, however, none have helped me. Following is what I use for sending email in my c# application, but I get an exception saying:
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 74.125.129.108:587
My code is:
try {
var client = new SmtpClient("smtp.gmail.com", 587) {
Credentials = new NetworkCredential("XXXX@gmail.com", "XXXX"),
EnableSsl = true
};
client.Send("XXXX@gmail.com", "XXXX@gmail.com", "test", "testbody");
Console.WriteLine("Sent");
Console.ReadLine();
}
catch
{ }