Example #1
0
 public ActionResult ForgetPwd(string email, FormCollection form)
 {
     if (!Common.Validate.IsEmail(email))
     {
         return(Content(ContentIcon.Error + "|邮箱格式错误"));
     }
     else
     {
         string error  = string.Empty;
         Member member = new MemberRepository().Search().Where(b => b.Email == email).First();
         if (member != null)
         {
             string body = "<p>尊敬的 <b>" + member.RealName + @"</b> 先生/女士,您好:</p>" +
                           "<p style='text-indent:21pt'>您于" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "进行了<b>忘记密码</b>操作,您的账户信息为:</p>" +
                           "<p style='text-indent:21pt'>用户名:" + member.UserName + "</p>" +
                           "<p style='text-indent:21pt'>密码:" + member.PwdNotMD5 + "</p>" +
                           "<p style='text-align:right'>本邮件系统自动发送,请勿回复。</p>";
             MailSettingRepository ml = new MailSettingRepository();
             var mt   = ml.GetList(1, 20).First();
             var mail = new Common.MailHelper(mt.MailServer, mt.MailFrom, mt.MailPassword, mt.MailPort ?? 465);
             mail.Send(email, "【找回密码】-" + CurrentSite.Title, body);
             return(Content(ContentIcon.Succeed + "|密码已经发送至您的邮箱,请注意查收"));
         }
         else
         {
             return(Content(ContentIcon.Error + "|无效的邮箱地址"));
         }
     }
 }
        public ActionResult Mail()
        {
            try
            {
                MailSettingRepository ml = new MailSettingRepository();

                List <MailSetting> list = ml.GetList(1, 20);
                MailSetting        obj  = (list.Count > 0 ? list.First() : new MailSetting());
                return(View(obj));
            }
            catch (Exception ex)
            {
                return(Content(ContentIcon.Error + "|" + ErrorWirter(RouteData, ex.Message)));
            }
        }
        public ActionResult Mail(FormCollection formCollection)
        {
            try
            {
                bool result = false;
                MailSettingRepository ml   = new MailSettingRepository();
                List <MailSetting>    list = ml.GetList(1, 20);
                MailSetting           obj  = new MailSetting();
                if (list.Count > 0)
                {
                    obj.LastUpdateDate = DateTime.Now;

                    obj.LastUpdateUserID = ID;

                    UpdateModel(obj);

                    result = ml.Update(obj) > 0 ? true : false;
                }
                else
                {
                    obj = new MailSetting()
                    {
                        CreateDate = DateTime.Now, CreateUserID = ID, IsDeleted = false
                    };

                    UpdateModel(obj);

                    result = ml.Insert(obj) > 0 ? true : false;
                }

                return(result ? Content(ContentIcon.Succeed + "|保存成功") : Content(ContentIcon.Error + "|保存失败"));
            }
            catch (Exception ex)
            {
                return(Content(ContentIcon.Error + "|" + ErrorWirter(RouteData, ex.Message)));
            }
        }