public async Task <IHttpActionResult> Put(MailConfigInfo info) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } info.UpdateTime = DateTime.Now; GlobalApplicationObject.Current.ApplicationContext.ConfigManager.SaveConfig <MailConfigInfo>(info); return(Ok(info)); }
public async Task <IHttpActionResult> Post(MailConfigInfo info) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } info.UpdateTime = DateTime.Now; ApplicationContext.ConfigManager.SaveConfig <MailConfigInfo>(info); return(Created <MailConfigInfo>("api/config/MailConfigInfo", info)); }
/// <summary> /// 发送重置密码邮件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LinkButton1_Click(object sender, EventArgs e) { AuthUserOperationPermission(Permission.SendMail); int reportid = IntParam; if (reportid != 0) { LossReport report = FacadeManage.aideNativeWebFacade.GetLossReport(reportid); AccountsInfo account = FacadeManage.aideAccountsFacade.GetAccountInfoByUserID(report.UserID); string site = FacadeManage.aideNativeWebFacade.GetConfigInfo(EnumerationList.SiteConfigKey.SiteConfig.ToString()).Field2; string sign = TextEncrypt.MD5EncryptPassword(report.ReportNo + report.UserID + report.ReportDate.ToString().Trim() + report.Random + ApplicationSettings.Get("ReportForgetPasswordKey")); string url = Game.Utils.Utility.UrlEncode(site + string.Format("/Member/Complaint-Setp-4.aspx?param={0}&sign={1}&test=test", report.ReportNo, sign)); //邮箱配置 ConfigInfo mail = FacadeManage.aideNativeWebFacade.GetConfigInfo(EnumerationList.SiteConfigKey.EmailConfig.ToString()); MailConfigInfo mailConfig = new MailConfigInfo(); mailConfig.Accounts = mail.Field1.Trim(); mailConfig.Password = mail.Field2.Trim(); mailConfig.Port = Convert.ToInt32(mail.Field4); mailConfig.SmtpServer = mail.Field3.Trim(); mailConfig.SmtpSenderEmail = mail.Field1.Trim(); mailConfig.LossreportUrl = ""; Dictionary <string, string> renderVals = new Dictionary <string, string>(); renderVals.Add("reportNO", report.ReportNo); renderVals.Add("userName", report.Accounts); renderVals.Add("url", url); renderVals.Add("mail", mail.Field1); renderVals.Add("sitename", FacadeManage.aideNativeWebFacade.GetConfigInfo(EnumerationList.SiteConfigKey.SiteConfig.ToString()).Field1); renderVals.Add("reason", ""); string file = TextUtility.GetFullPath("/Config/lossReportSuccess.config"); TMLForgetConfigManager.ConfigFilePath = file; MailTMLConfigInfo tmlMail = new MailTMLConfigInfo(TMLForgetConfigManager.LoadConfig().MailContent.Text, TMLForgetConfigManager.LoadConfig().MailTitle); Game.Facade.Mail.EmailForgetPassword emailFoget = new Game.Facade.Mail.EmailForgetPassword(mailConfig, tmlMail, renderVals); //发送邮件 try { emailFoget.Send(report.ReportEmail); report.ProcessStatus = 1; FacadeManage.aideNativeWebFacade.UpdateLossReport(report); MessageBox("成功发送“申诉成功”邮件"); } catch (Exception ex) { MessageBox("邮件发送失败" + ex.ToString()); } } }
protected void btnSend_Click(object sender, EventArgs e) { AuthUserOperationPermission(Permission.SendMail); int reportid = IntParam; if (reportid != 0) { LossReport report = FacadeManage.aideNativeWebFacade.GetLossReport(reportid); AccountsInfo account = FacadeManage.aideAccountsFacade.GetAccountInfoByUserID(report.UserID); string site = FacadeManage.aideNativeWebFacade.GetConfigInfo(EnumerationList.SiteConfigKey.SiteConfig.ToString()).Field2; //邮箱配置 ConfigInfo mail = FacadeManage.aideNativeWebFacade.GetConfigInfo(EnumerationList.SiteConfigKey.EmailConfig.ToString()); MailConfigInfo mailConfig = new MailConfigInfo(); mailConfig.Accounts = mail.Field1.Trim(); mailConfig.Password = mail.Field2.Trim(); mailConfig.Port = Convert.ToInt32(mail.Field4); mailConfig.SmtpServer = mail.Field3.Trim(); mailConfig.SmtpSenderEmail = mail.Field1.Trim(); mailConfig.LossreportUrl = ""; Dictionary <string, string> renderVals = new Dictionary <string, string>(); renderVals.Add("reportNO", report.ReportNo); renderVals.Add("userName", report.Accounts); renderVals.Add("mail", mail.Field1); renderVals.Add("url", ""); renderVals.Add("sitename", FacadeManage.aideNativeWebFacade.GetConfigInfo(EnumerationList.SiteConfigKey.SiteConfig.ToString()).Field1); renderVals.Add("reason", txtContent.Text); string file = TextUtility.GetFullPath("/Config/lossReportFailure.config"); TMLForgetConfigManager.ConfigFilePath = file; MailTMLConfigInfo tmlMail = new MailTMLConfigInfo(TMLForgetConfigManager.LoadConfig().MailContent.Text, TMLForgetConfigManager.LoadConfig().MailTitle); Game.Facade.Mail.EmailForgetPassword emailFoget = new Game.Facade.Mail.EmailForgetPassword(mailConfig, tmlMail, renderVals); //发送邮件 try { emailFoget.Send(report.ReportEmail); report.ProcessStatus = 2; FacadeManage.aideNativeWebFacade.UpdateLossReport(report); MessageBox("成功发送“申诉失败”邮件"); } catch (Exception ex) { MessageBox("邮件发送失败" + ex.ToString()); } } }