The following code is mine and works in my machine (Windows 7):
var fromAddress = "[email protected]";
var toAddress = "[email protected]";
const string fromPassword = "dfdfdf";
string subject = "Test Mail Please ignore";
string body = "Test";
body += "Email: ";
body += "Subject: ";
body += "Question:";
var smtp = new System.Net.Mail.SmtpClient();
smtp.Host = "QAsmtp.company.net";
smtp.Port = 25;
//'smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new System.Net.NetworkCredential("csweb123lab", fromPassword);
smtp.Timeout = 300000;
smtp.Send(fromAddress, toAddress, subject, body);
I copied this code and run into my remote machine Windows 2008 R2 SP1
(64bit) that is also in the company network.
I am getting the below error message :
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: 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 pinged SMTP host response from this machine and its responding properly. I don't understand why I get this error frequently.