所以这是我的代码:
protected void BtnSubmit_Click(object sender, EventArgs e)
{
MailMessage msg = new MailMessage();
msg.From = new MailAddress("Kamal.s.buqlieh@hotmail.com","Kamal");
msg.To.Add(TxtEmailPass.Text);
msg.Subject = "Forget Password!";
msg.Body = "your password is:";
SmtpClient mySmtpClient = new SmtpClient();
mySmtpClient.Host = "www.Hotmail.com";
NetworkCredential nc = new NetworkCredential();
nc.UserName = "Kamal.s.buqlieh@hotmail.com";
nc.Password = "";
mySmtpClient.UseDefaultCredentials = true;
mySmtpClient.Credentials = nc;
mySmtpClient.Port = 587;
mySmtpClient.EnableSsl = true;
mySmtpClient.Send(msg);
}
它一直告诉我
"由于目标机器主动拒绝它,因此无法建立连接157.56.198.204:587"
任何人都可以帮助我吗?
答案 0 :(得分:1)
您的主机地址错误。你使用过“www.Hotmail.com”。
mySmtpClient.Host = "www.Hotmail.com";
为Hotmail帐户试用此SMTP设置:
Hotmail SMTP服务器名称: smtp.live.com
Hotmail SMTP端口: 25或465
答案 1 :(得分:0)
如果您使用的是Microsoft Outlook&在Outlook Connector中,您可以像定义常规POP3电子邮件帐户一样定义Hotmail帐户:
Hotmail Incoming Mail Server (POP3) - pop3.live.com (logon using Secure Password Authentification - SPA, mail server port: 995)
Hotmail Outgoing Mail Server (SMTP) - smtp.live.com (TLS enabled, port 587)
请参阅Incoming and Outgoing Mail Server Settings for Hotmail, Yahoo! Mail, GMail, MSN, AOL and more