用户注册后如何发送电子邮件通知以接收他的忘记密码
问题描述:
用户注册后如何发送电子邮件通知以接收他的忘记密码
how to send email notification after user get registered to recieve his forget password
答
使用 PasswordRecovery 控件,它是登录控制并帮助找回忘记密码的密码.它使用户可以请求包含新密码或已经与他或她的用户名或电子邮件相关联的密码的电子邮件.
看看:
ASP.NET中的密码恢复控制 [ ^ ]
密码恢复 [ ^ ]
Use PasswordRecovery control, it is a part of Login controls and helps to recover password who have forgotten their passwords. It enables a user to request an e-mail message containing either a new password or the password already associated with his or her user name or email.
Have a look:
PasswordRecovery Control in ASP.NET[^]
Password Recovery[^]
如果您有邮件服务器:
if you have a mail server:
public bool SendEmail(string subj, string message)
{
bool sent = false;
try
{
SmtpClient client = new SmtpClient(this.strMailServer);
client.UseDefaultCredentials = true;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage email = new MailMessage();
email.From = new MailAddress(this.strSendFrom);
email.To.Add(new MailAddress(this.strSendTo));
email.CC.Add(new MailAddress(this.strSendtoCC));
email.Subject = subj;
email.Body = message;
client.Send(email);
sent = true;
}
catch (Exception ex)
{
throw ex;
}
return sent;
}
请包括名称空间"using System.Net.Mail;"
并包含此编码
SmtpClient smtp =新的SmtpClient();
MailMessage msg = new MailMessage();
msg.From =新的MailAddress(发件人地址");
msg.To.Add(新的MailAddress(收件人地址"));
//设置邮件的主题
msg.Subject =您的主题";
//将邮件正文的格式设置为HTML
msg.IsBodyHtml = true;
//设置邮件的正文
msg.Body =您的内容;
//为Gmail服务创建主机
smtp.Host ="smtp.gmail.com";
smtp.UseDefaultCredentials = true;
smtp.Credentials =新的System.Net.NetworkCredential(发件人地址",密码");
smtp.EnableSsl = true;
smtp.Send(msg);
Please include namespace "using System.Net.Mail;"
and include this coding
SmtpClient smtp = new SmtpClient();
MailMessage msg = new MailMessage();
msg.From = new MailAddress("From Address");
msg.To.Add(new MailAddress("To Address"));
// Set the subject of the mail message
msg.Subject = "Your Subject";
// Set the format of the mail message body as HTML
msg.IsBodyHtml = true;
// Set the body of the mail message
msg.Body = "Your Content;
//Create host for Gmail service
smtp.Host = "smtp.gmail.com";
smtp.UseDefaultCredentials = true;
smtp.Credentials = new System.Net.NetworkCredential("From Address", " Password");
smtp.EnableSsl = true;
smtp.Send(msg);