I am trying to send Email through my C# code but I am getting SmtpException
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 173.194.67.109:587
Here is how I am sending Email:
string HostAddress = "smtp.gmail.com";
MailMessage msg = new MailMessage();
msg.From = new MailAddress(fromEmail);
msg.Subject = "Test Email";
msg.Body = "Hi testing invoice";
msg.IsBodyHtml = true;
msg.To.Add(new MailAddress("ramshaafaq2012@gmail.com"));
SmtpClient client = new SmtpClient();
client.Host = HostAddress;
client.EnableSsl = true;
NetworkCredential creadit = new NetworkCredential();
creadit.UserName = msg.From.Address;
creadit.Password = Password;
client.UseDefaultCredentials = true;
client.Credentials = creadit;
client.Port = 587;
client.Send(msg);
A friend suggested to make some some changes in the Web.config file as Maybe a firewall is blocking the request. What changes should I make to resolve this issue?