我正在尝试通过我的 C# 代码发送电子邮件,但我得到了SmtpException
连接尝试失败,因为连接的一方在一段时间后没有正确响应,或者连接失败,因为连接的主机没有响应 173.194.67.109:587
这是我发送电子邮件的方式:
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);