我正在使用下面的代码,每次在Vista/Win7上都能很好地工作。为什么SmtpClient在XP/Vista/Win7上的表现会有所不同
private void SendEmail(string subject, string body, string attach)
{
using (MailMessage message = new MailMessage("[email protected]", "[email protected]", subject, body))
{
message.IsBodyHtml = true;
if (!string.IsNullOrEmpty(attach))
{
Attachment attached = new Attachment(attach);
message.Attachments.Add(attached);
}
SmtpClient client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential("[email protected]", "password"),
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network
};
client.Send(message);
}
}
但是在Windows XP中我得到:
No connection could be made because the target machine actively refuses it
我检查和Windows防火墙是完全禁用...
远程登录失败。由于某些原因,我们所有的XP机器都发生这种情况,Vista Vista也没有。我将不得不看看他们都安装了什么...... – Tim 2010-01-27 14:08:45
但请注意,在某些版本的Windows上,默认情况下未安装“telnet.exe”。 – 2012-12-27 17:36:42