/// <summary> /// 注册邮箱 /// </summary> /// <param name="toEmail">接收者邮件</param> /// <param name="activateUrl">激活邮件地址</param> /// <param name="_result">处理结果</param> /// <returns></returns> public QssResult QssRegisterEmail(string toEmail, string activateUrl, string code, out string _result) { var result = QssGetUserByAccount(HttpContext.Current.User.Identity.Name, out User user); if (result != QssResult.Success) { _result = "出现错误!请重试,多次出现该错误请联系管理员."; return(QssResult.Fail); } string body = $"请点击<a href='{activateUrl}'> 此处 </a>来激活你的邮箱,该链接30分钟内有效. 若是链接不能跳转, 请将以下链接复制到浏览器地址栏进行跳转:<br />{activateUrl}"; if (QssEmailHelper.SendMail(toEmail, "四川农业大学问卷调查与投票系统激活邮件", user.Name, body)) { try { // 保存邮箱和激活码 user.Email = toEmail; user.ACode = code; user.CodeFailTime = DateTime.Now.AddMinutes(30); Update(user); // 提示并跳转 _result = "激活邮件已发送,请查收邮件进行邮箱确认!链接30分钟内有效."; return(QssResult.Success); } catch (Exception exception) { // 保存失败 QssLogHelper.Log("保存邮箱失败", $"保存用户: {user.Name}({user.Account}) 的邮箱: {toEmail} 失败!失败原因:{exception.Message}", QssLogType.Error, exception); _result = "保存邮箱失败!请重试."; return(QssResult.Fail); } } _result = "发送激活邮件失败!请重试."; return(QssResult.Fail); }
public void Execute(IJobExecutionContext context) { if (QssEmailHelper.EmailEnqueueCount() == 0) { return; } var email = QssEmailHelper.DequeueEmail(); QssEmailHelper.SendMail(email.ToEmail, email.Subject, email.ToName, email.BodyInfo); }