if (Page.IsValid)
{
MembershipUser user = Membership.GetUser(textboxId.Text.Trim());
if (user == null)
{
labelMessage.Text = "此帐号不存在!";
}
else
{
string email = user.Email;
if (email == textboxPass.Text.Trim())
{
user.UnlockUser();
string newPass = user.ResetPassword();
if (newPass != null)
{
MailMessage mail = new MailMessage();
mail.To = textboxPass.Text.Trim();
mail.From = "pwqzc1688@gmail.com";
mail.Subject = "99收藏夹--找回密码";
mail.BodyFormat = MailFormat.Html;
//mailMsg.Priority = MailPriority.High;
mail.Body = "尊敬的"+textboxId.Text.Trim()+":<br/>您好!<br/>您在99收藏夹的密码已经被更新为:<span style='color:red;'>"+newPass+"</span><br/>请您登陆后更改密码,谢谢";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "pwqzc1688"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "你的密码"); //set your password here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "1");
SmtpMail.SmtpServer = "smtp.gmail.com"; //your real server goes here
SmtpMail.Send(mail);
labelMessage.Text = "找回密码成功,密码已经成功的发送到您的邮箱,请查收!";
}
else
{
labelMessage.Text = "您的输入正确,但是找回密码失败,请再单击找回密码按钮!";
}
}
else
{
labelMessage.Text = "找回密码失败,帐号和Email不吻合!";
}
}