将帐号密码发送到邮箱
好多网站都有这种功能:就是用户忘记登陆密码了,经过一系列正确操作后,网站会把该用户的密码发送到该用户注册时填写的邮箱里。程序怎么实现?
------解决方案--------------------用。net写个邮件发送的程序就可以了。网上这样的代码很多。
------解决方案--------------------using System.Net.Mail;
MailMessage
------解决方案--------------------public static bool sendMail(string strSubject,string content,string eMailAddress) {
if (eMailAddress.Length < 2)
{
return false;
}
bool hasSend = true;
string strSMTPServer = ConfigurationManager.AppSettings[ "smtpAddress "];
string strSMTPUser = ConfigurationManager.AppSettings[ "smtpUser "];
string strSMTPPassword = ConfigurationManager.AppSettings[ "smtpPassword "];
string strFrom = strSMTPUser;
SmtpClient client = new SmtpClient(strSMTPServer);
client.Credentials = new NetworkCredential(strFrom, strSMTPPassword);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage message = new MailMessage();
message.From = new MailAddress(strFrom);
message.Subject = strSubject;
message.Body = content;
message.To.Add(eMailAddress);
message.SubjectEncoding = Encoding.UTF8;
message.BodyEncoding = Encoding.UTF8;
message.IsBodyHtml = true;
try
{
client.Send(message);
}
catch (Exception ex)
{
return false;
}
return hasSend;
}