zoukankan      html  css  js  c++  java
  • 邮件找回密码类

    using System;
    using System.Data;
    using System.Configuration;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Text;
    using System.Net.Mail;
    using System.Net;

    namespace Web.Common
    {
    ///<summary>
    /// 找回密码类
    ///</summary>
    public class MyEmail
    {
    #region 找回密码
    ///<summary>
    /// 功能:用户找回密码
    ///</summary>
    ///<param name="ToEmail">目的地地址</param>
    ///<param name="memberid">会员ID</param>
    ///<returns></returns>
    public static bool SendMail(string ToEmail,string memberid)
    {
    string Email = "m.sh.lin0328@163.com";
    string password = "abcd";
    Encoding EnCode = Encoding.UTF8;
    System.Net.Mail.MailMessage Message = new System.Net.Mail.MailMessage();
    Message.From = new MailAddress(Email, "新郑网购会员管理中心", EnCode);
    Message.To.Add(new MailAddress(ToEmail, "尊敬的用户", EnCode));
    Message.Subject = "新郑网购网找回密码";
    Message.SubjectEncoding = EnCode;
    //CC为抄送,即发给用户的同时,再发送给Email
    //Message.CC.Add(new MailAddress(Email,"房产巴巴网"));
    StringBuilder MailContent = new StringBuilder();
    MailContent.Append("尊敬的用户:<br/>");
    MailContent.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您好!你于");
    MailContent.Append(DateTime.Now.ToLongTimeString());
    MailContent.Append("通过<a href='#'>新郑网购</a>管理中心审请找回密码。");
    MailContent.Append("<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;为了安全起见,请用户点击以下链接重设个人密码:");
    string url = "http://www.hnjcg.com/getPass.aspx?memberid=" + memberid + "&email=" + ToEmail;
    MailContent.Append("<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='" + url + "'>" + url + "</a>");
    Message.Body = MailContent.ToString();
    Message.BodyEncoding = EnCode;
    Message.IsBodyHtml = true;

    try
    {
    SmtpClient smtp = new SmtpClient("smtp.163.com", 25);
    smtp.Credentials = new NetworkCredential(Email, password);
    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
    smtp.Send(Message);
    }
    catch (Exception)
    {
    return false;
    }
    finally
    {
    Message.Dispose();
    }
    return true;
    }
    #endregion
    }
    }
    
    
    
    
    
    
    
    
          接收邮箱返回数据并重置密码:
    
    	string  memeberid = "";//用来接收找回密码时返回的email地址,与会员编号
            protected void Page_Load(object sender, EventArgs e)
            {
                if (Request.QueryString["email"] != null)
                {
                    email = Request.QueryString["email"].ToString();
                }
                if (Request.QueryString["memberid"] != null)
                {
                    memeberid = Request.QueryString["memberid"].ToString();
                    modelMember = bllMember.GetModel(long.Parse(memeberid));
                    modelMember.PassWord = TianDao.Common.DEncrypt.DESEncrypt.Encrypt("123456");
                    if (modelMember.Email == email)//验证邮箱地址是否为用户注册时候的邮箱地址 
                    {
                        bllMember.Update(modelMember);
                        Response.Write("<script>alert('您的密码已重置,默认密码为123456,请尽快修改密码!');window.location.href='../login.aspx';</script>");
                    }
                }
                if (!IsPostBack)
                {
                   
                }
            }
  • 相关阅读:
    Linux 禁用笔记本触摸板
    Linux 下安装android
    关于JAVA多线程的那些事__初心者
    ADT下开发环境的配置--个人配置啦 Eclipse Color Themes
    关于权限系统的一些思考
    关于线程安全的单例模式的讨论
    说下Fedora下把SpiderMonkey放入Eclipse内编译的过程
    基于Eclipse构建Hadoop源码阅读环境
    Hadoop生态上几个技术的关系与区别:hive、pig、hbase 关系与区别
    CentOS6.5安装配置
  • 原文地址:https://www.cnblogs.com/shanlin/p/2205372.html
Copyright © 2011-2022 走看看