[英]How to send an Email in asp.net using c#
so here is my code: 所以这是我的代码:
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);
}
it keeps telling me that 它一直告诉我
"No connection could be made because the target machine actively refused it 157.56.198.204:587" “无法建立连接,因为目标计算机主动拒绝它157.56.198.204:587”
anyone can help me with this? 有人可以帮助我吗?
Your host address is wrong. 您的主机地址错误。 you have used "www.Hotmail.com". 您已使用“ www.Hotmail.com”。
mySmtpClient.Host = "www.Hotmail.com";
Try this SMTP settings for your Hotmail account: 请为您的Hotmail帐户尝试以下SMTP设置:
Hotmail SMTP server name: smtp.live.com Hotmail SMTP服务器名称: smtp.live.com
Hotmail SMTP port: 25 or 465 Hotmail SMTP端口: 25或465
If you are using Microsoft Outlook & the Outlook Connector, you can define your Hotmail account just like any regular POP3 email account: 如果您使用的是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)
See Incoming and Outgoing Mail Server Settings for Hotmail, Yahoo! 请参阅Hotmail,Yahoo!的传入和传出邮件服务器设置。 Mail, GMail, MSN, AOL and more 邮件,GMail,MSN,AOL等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.