public bool SendInviteProjectEmail(SendEmailLogicModel model) { var titletxt = model.MailContentLogicModel.MailTitle; var bodytxt = model.MailContentLogicModel.Content; bodytxt = bodytxt.Replace("{webname}", model.MailLogicModel.WebName); bodytxt = bodytxt.Replace("{weburl}", model.MailLogicModel.WebUrl); bodytxt = bodytxt.Replace("{webtel}", model.MailLogicModel.WebTel); bodytxt = bodytxt.Replace("{linkurl}", model.MailLogicModel.AbsUrl + "?code=" + TokenGenerator.EncodeToken(model.MailLogicModel.EmailCode)); try { SendEmailLogicModel.SendMail(model.MailLogicModel.EmailSmtp, model.MailLogicModel.EmailSsl, model.MailLogicModel.EmailUserName, TokenGenerator.DecodeToken(model.MailLogicModel.EmailPassWord), model.MailLogicModel.EmailNickName, model.MailLogicModel.EmailFrom, model.MailLogicModel.EmailTo, titletxt, bodytxt); } catch { return(false); } return(true); }
public bool SendForgetPassowrdEmail(SendEmailLogicModel model) { if (!_userRepository.Query().Any(x => x.Email == model.MailLogicModel.EmailTo)) { return(false); } var userModel = _userRepository.Query().FirstOrDefault(x => x.Email == model.MailLogicModel.EmailTo); using (var unitOfwork = _unitOfWorkFactory.GetCurrentUnitOfWork()) { if (userModel != null) { userModel.ResetPasswordToken = TokenGenerator.EncodeToken(model.MailLogicModel.EmailTo + "&" + DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)); userModel.ExpiredTime = DateTime.Now.AddHours(1); _userRepository.Save(userModel); } unitOfwork.Commit(); } var titletxt = model.MailContentLogicModel.MailTitle; var bodytxt = model.MailContentLogicModel.Content; bodytxt = bodytxt.Replace("{webname}", model.MailLogicModel.WebName); bodytxt = bodytxt.Replace("{weburl}", model.MailLogicModel.WebUrl); bodytxt = bodytxt.Replace("{webtel}", model.MailLogicModel.WebTel); if (userModel != null) { bodytxt = bodytxt.Replace("{linkurl}", model.MailLogicModel.AbsUrl + "?code=" + userModel.ResetPasswordToken); } try { SendEmailLogicModel.SendMail(model.MailLogicModel.EmailSmtp, model.MailLogicModel.EmailSsl, model.MailLogicModel.EmailUserName, TokenGenerator.DecodeToken(model.MailLogicModel.EmailPassWord), model.MailLogicModel.EmailNickName, model.MailLogicModel.EmailFrom, model.MailLogicModel.EmailTo, titletxt, bodytxt); } catch { return(false); } return(true); }