예제 #1
0
    /// <summary>
    /// 发送邮件

    /// </summary>
    /// <param name="loginName"></param>
    /// <param name="email"></param>
    /// <param name="validUrl"></param>
    /// <param name="domain"></param>
    /// <param name="isResend">是否为重发</param>

    private void ReSendValidMail(string loginName, string email, string validUrl, string domain)
    {
        RegisterMail mail = new RegisterMail();

        loginName = Tz888.Common.DEncrypt.DEncrypt.Decrypt(loginName);
        string url = Server.MapPath("../" + mail.GetMailTemplateUrl()); //模板地址

        string isSend    = mail.GetCookies(loginName);
        string isSuccess = mail.GetCookies("SUCCESS" + loginName);  //是否已经通过验证

        if ((isSend == "" || isSend == string.Empty) || (isSuccess == "" || isSuccess == string.Empty))
        {
            try
            {
                mail.SendMail(url, loginName, email, validUrl, domain);
            }
            catch (Exception exp)
            {
                return;
            }
            mail.CreateCookies(loginName, email, "");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string actionType = Request.QueryString["act"];
        string name       = Request.QueryString["logname"];
        string mail       = Request.QueryString["email"];

        if (string.IsNullOrEmpty(actionType) ||
            string.IsNullOrEmpty(name) ||
            string.IsNullOrEmpty(mail))
        {
            return;
        }
        else
        {
            actionType = Tz888.Common.DEncrypt.DEncrypt.Decrypt(actionType);
        }

        if (actionType == "register")
        {
            divreg.Attributes.Add("style", "");
            divahead.Attributes.Add("style", "");
            divafter.Attributes.Add("style", "display:none");
            divvalid.Attributes.Add("style", "display:none");

            RegisterMail mailV = new RegisterMail();


            string validurl = Request.RawUrl.Replace("ValidSuccessPersonal.aspx", "ValidEMailPersonal.aspx");
            validurl  = validurl.Substring(0, validurl.IndexOf("&act=") + "&act=".Length);
            validurl += Server.UrlEncode(Tz888.Common.DEncrypt.DEncrypt.Encrypt("valid"));

            hpvalidurl.HRef = validurl;
        }

        if (actionType == "valid")
        {
            try
            {
                divreg.Attributes.Add("style", "display:none");
                divvalid.Attributes.Add("style", "");
                divahead.Attributes.Add("style", "display:none");
                divafter.Attributes.Add("style", "");

                name = Tz888.Common.DEncrypt.DEncrypt.Decrypt(Request.QueryString["logname"]);
                mail = Tz888.Common.DEncrypt.DEncrypt.Decrypt(Request.QueryString["email"]);

                LoginInfoBLL login = new LoginInfoBLL();
                RegisterMail mailB = new RegisterMail();

                //防止刷新而导致邮件重发

                string CheckUp = mailB.GetCookies("SUCCESS" + name);
                if (CheckUp == "" || CheckUp == string.Empty)
                {
                    login.ValidUser(name);

                    string url    = mailB.GetMailSucessTemplateUrl();
                    string domain = "http://" + Request.ServerVariables["SERVER_NAME"].ToString();

                    mailB.SendSuccessMail(Server.MapPath(url), name, mail, domain);
                    mailB.CreateCookies("SUCCESS" + name, mail, "");
                }
            }
            catch (Exception exp)
            {
                Tz888.Common.MessageBox.ShowBack("非法访问。" + exp.Message);
            }
        }
    }