C# 如何使用c在asp.net中发送电子邮件#
这是我的代码:C# 如何使用c在asp.net中发送电子邮件#,c#,asp.net,email,C#,Asp.net,Email,这是我的代码: 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.Su
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”
有人能帮我吗 您的主机地址错误。您使用了“www.Hotmail.com” 请为您的Hotmail帐户尝试以下SMTP设置:
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)
- Hotmail SMTP服务器名称:SMTP.live.com
- Hotmail SMTP端口:25或465
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)
请参见IMHO防火墙阻止连接或承载服务的进程未在该端口上侦听,这可能是因为该端口根本未运行或正在另一个端口上侦听。