/// <summary> /// 下单发邮件 /// </summary> /// <param name="pMailTo"></param> /// <param name="pTitle"></param> /// <param name="pBody"></param> public void SendMail(string pMailTo, string pTitle, string pBody) { FromSetting fs = new FromSetting(); fs.SMTPServer = "smtp.exmail.qq.com"; fs.SendFrom = "*****@*****.**"; fs.UserName = "******"; fs.Password = "******"; Mail.SendMail(fs, pMailTo, pTitle, pBody, null); }
protected override ApplyRD ProcessRequest(APIRequest <ApplyRP> pRequest) { var rd = new ApplyRD(); FromSetting fs = new FromSetting(); fs.SMTPServer = "smtp.exmail.qq.com"; fs.SendFrom = "*****@*****.**"; fs.UserName = "******"; fs.Password = "******"; string mailTo = "*****@*****.**"; string[] s = new string[1]; var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; T_CTW_LEventThemeBLL bllTheme = new T_CTW_LEventThemeBLL(loggingSessionInfo); T_CTW_LEventThemeEntity entityTheme = bllTheme.GetByID(para.ThemeId); DataSet dsCustomer = bllTheme.GetCustomerInfo(); if (dsCustomer.Tables[0] == null) { rd.errCode = 1; rd.errMsg = "商户信息不存在!"; return(rd); } t_customerEntity entityCustomer = DataTableToObject.ConvertToObject <t_customerEntity>(dsCustomer.Tables[0].Rows[0]); if (entityTheme != null) { string strSubject = "活动申请"; string strBody = "商户名称:" + entityCustomer.customer_name + "<br/>联系人:" + entityCustomer.customer_contacter + "<br/>联系方式:" + entityCustomer.customer_tel + "<br/>活动名称:" + entityTheme.ThemeName + "<br/>申请时间:" + DateTime.Now; Mail.SendMail(fs, mailTo, strSubject, strBody, s); rd.errCode = 0; } return(rd); }
public void SendMail(LoggingSessionInfo loggingSessionInfo, string strTitle, string strBody, string strSupportType) { FromSetting fs = new FromSetting(); fs.SMTPServer = ConfigurationManager.AppSettings["SMTPServer"].ToString(); fs.SendFrom = ConfigurationManager.AppSettings["SendFrom"].ToString(); fs.UserName = ConfigurationManager.AppSettings["SendFrom"].ToString(); //获取加密密码 string emailEncPwd = ConfigurationManager.AppSettings["EmailPassword"].Trim(); //获取解密口令 string decToken = ConfigurationManager.AppSettings["DecToken"].ToString(); //获取解密密码 string emailDecPwd = ZmindFx.ZmindEncryptTool.Decrypt(emailEncPwd, decToken); fs.Password = emailDecPwd; string mailTo = ConfigurationManager.AppSettings["MailTo"].ToString(); // "*****@*****.**"; bool blResult = Mail.SendMail(fs, mailTo, strTitle, strBody, null); if (blResult) { ApplicationSupportLogBLL bllLog = new ApplicationSupportLogBLL(loggingSessionInfo); ApplicationSupportLogEntity entityLog = new ApplicationSupportLogEntity(); entityLog.SurportType = strSupportType; entityLog.Title = strTitle; entityLog.Content = strBody; entityLog.SentUser = loggingSessionInfo.CurrentUser.User_Name; entityLog.SentUserPhone = loggingSessionInfo.CurrentUser.User_Telephone; entityLog.SentEMail = loggingSessionInfo.CurrentUser.User_Email; entityLog.SentUserSex = 1; entityLog.ReceiveEMail = mailTo; entityLog.IsSuccess = 1; entityLog.CustomerId = loggingSessionInfo.ClientID; bllLog.Create(entityLog); } }
/// <summary> /// 校园专家 重置密码 /// </summary> /// <returns></returns> public string ForgetPassword() { string content = string.Empty; var respData = new ambassadorLoginInRespData(); try { //接收参数 string reqContent = HttpContext.Current.Request["ReqContent"]; var reqObj = reqContent.DeserializeJSONTo <ambassadorLoginInReqData>(); reqObj = reqObj == null ? new ambassadorLoginInReqData() : reqObj; //获取客户ID if (!string.IsNullOrEmpty(reqObj.common.customerId)) { customerId = reqObj.common.customerId; } //初始化返回对象 respData.content = new ambassadorLoginInRespContentData(); respData.content.vipList = new List <ambassadorLoginInRespContentDataItem>(); //用户登录信息 var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1"); OnlineShoppingItemBLL itemService = new OnlineShoppingItemBLL(loggingSessionInfo); var vipInfo = itemService.ForgetPassword(reqObj.special.email); if (vipInfo != null && vipInfo.Count > 0) { //生成随机数 6位 Random rd = new Random(); string code = rd.Next(100000, 999999).ToString(); VipBLL vipBLL = new VipBLL(loggingSessionInfo); VipEntity entity = new VipEntity(); entity = vipBLL.GetByID(vipInfo[0].VIPID); entity.VipPasswrod = MD5Helper.Encryption(MD5Helper.Encryption(code) + entity.Col4); entity.LastUpdateTime = DateTime.Now; vipBLL.Update(entity); #region 邮件发送 try { XmlManager xml = new XmlManager(ConfigurationManager.AppSettings["xmlFile"]); FromSetting fs = new FromSetting(); fs.SMTPServer = xml.SelectNodeText("//Root/AsusMail//SMTPServer", 0); fs.SendFrom = xml.SelectNodeText("//Root/AsusMail//MailSendFrom", 0); fs.UserName = xml.SelectNodeText("//Root/AsusMail//MailUserName", 0); fs.Password = xml.SelectNodeText("//Root/AsusMail//MailUserPassword", 0); Mail.SendMail(fs, entity.Col7 + "," + xml.SelectNodeText("//Root/AsusMail//MailTo", 0), xml.SelectNodeText("//Root/AsusMail//MailTitle", 0), entity.VipRealName + ":你好,你的新密码为:" + code, null); } catch { respData.code = "111"; respData.description = "邮箱发送失败,请稍后重试"; content = respData.ToJSON(); return(content); } #endregion List <ambassadorLoginInRespContentDataItem> list = new List <ambassadorLoginInRespContentDataItem>(); foreach (var item in vipInfo) { ambassadorLoginInRespContentDataItem info = new ambassadorLoginInRespContentDataItem(); info.VipID = item.VIPID; info.VipPassword = code; info.Email = item.Email; list.Add(info); } respData.content.vipList = list; } else { respData.code = "111"; respData.description = "邮箱不存在"; } } catch (Exception ex) { respData.code = "103"; respData.description = "数据库操作错误"; respData.exception = ex.ToString(); } content = respData.ToJSON(); return(content); }
private void DoWork() { while (true) { try { ConfigurationManager.RefreshSection("appSettings"); var time = ConfigurationManager.AppSettings["Timing"]; TimeSpan.TryParse(time, out _timeSpan); if (DateTime.Now.TimeOfDay.Hours == _timeSpan.Hours) { //支持配置多客户 string[] customerIDs = ConfigurationManager.AppSettings["CustomerIDs"].Split(','); foreach (string customerID in customerIDs) { loggingSessionInfo = Default.GetBSLoggingSession(customerID, "1"); var eventsService = new LEventsBLL(loggingSessionInfo); LEventsEntity queryEntity = new LEventsEntity(); queryEntity.EventType = 0; var data = eventsService.WEventGetWebEvents(queryEntity, 0, 100000000); foreach (var item in data) { XieHuiBaoBLL b = new XieHuiBaoBLL(loggingSessionInfo, "vip"); List <DefindControlEntity> l = new List <DefindControlEntity>(); PageResultEntity pageEntity = null; try { pageEntity = b.GetPageDataByEventID(l, 100000000, 0, item.EventID); } catch (Exception e) { Loggers.Debug(new DebugLogInfo { Message = string.Format("{0} {1} (EventID:{3})报名人员信息通知邮件发送{2}", DateTime.Now.ToShortDateString(), DateTime.Now.TimeOfDay, "失败", item.EventID) }); Loggers.Exception(new BasicUserInfo(), e); continue; } if (pageEntity.GridData != null) { if (pageEntity.GridData.Rows.Count == 0) { continue; } } GridInitEntity g = GetInitGridDataByEventID(item.EventID); if (pageEntity != null && pageEntity.GridData != null) { #region 替换标题信息 if (g != null && g.GridColumnDefinds != null) { if (pageEntity.GridData.Columns.Contains("ROW_NUMBER")) { pageEntity.GridData.Columns.Remove("ROW_NUMBER"); } if (pageEntity.GridData.Columns.Contains("SignUpID")) { pageEntity.GridData.Columns.Remove("SignUpID"); } if (pageEntity.GridData.Columns.Count == 0) { continue; } for (int i = 0; i < pageEntity.GridData.Columns.Count; i++) { for (int j = 0; j < g.GridColumnDefinds.Count; j++) { if (pageEntity.GridData.Columns[i].ColumnName.ToLower() == g.GridColumnDefinds[j].DataIndex.ToLower()) { pageEntity.GridData.Columns[i].ColumnName = g.GridColumnDefinds[j].ColumnText; break; } } } } #endregion } //数据获取 Workbook wb = DataTableExporter.WriteXLS(pageEntity.GridData, 0); wb.Worksheets[0].Name = "参加活动人员信息"; string savePath = ConfigurationManager.AppSettings["FileURL"]; if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); } savePath = savePath + "/" + item.Title + DateTime.Now.ToString("yyyyMMdd") + ".xls"; wb.Save(savePath);//保存Excel文件 #region 邮件发送 FromSetting fs = new FromSetting(); fs.SMTPServer = ConfigurationManager.AppSettings["SmtpServer"]; fs.SendFrom = ConfigurationManager.AppSettings["MailSendFrom"]; fs.UserName = ConfigurationManager.AppSettings["MailUserName"]; fs.Password = ConfigurationManager.AppSettings["MailUserPassword"]; string mailTo = ConfigurationManager.AppSettings["MailTo"]; string isSendMail = ConfigurationManager.AppSettings["IsSendMailToCreator"]; //是否发送成功 bool result = false; if (!string.IsNullOrEmpty(mailTo)) { result = Mail.SendMail(fs, mailTo, ConfigurationManager.AppSettings["MailTitle"], ConfigurationManager.AppSettings["Subject"], savePath.Split(',')); } if (isSendMail == "1") { if (!string.IsNullOrEmpty(item.Email)) { if (DateTime.Now < DateTime.Parse(item.EndTime)) { //等于0表示不发送邮件 if (item.MailSendInterval == null || item.MailSendInterval == 0) { continue; } //日期差与间隔时间取余判断是否符合发送邮件日期 int dateDiff = ((TimeSpan)(DateTime.Now.Date - item.LastUpdateTime.Value.Date)).Days; if (dateDiff % item.MailSendInterval != 0) { continue; } result = Mail.SendMail(fs, item.Email, ConfigurationManager.AppSettings["MailTitle"], ConfigurationManager.AppSettings["Subject"], savePath.Split(',')); Loggers.Debug(new DebugLogInfo { Message = string.Format("{0} {1} (EventID:{3})报名人员信息通知邮件发送{2}", DateTime.Now.ToShortDateString(), DateTime.Now.TimeOfDay, result ? "成功" : "失败", item.EventID) }); } } } #endregion } } } } catch (Exception ex) { Loggers.Exception(new BasicUserInfo(), ex); } Thread.Sleep(new TimeSpan(0, 1, 0, 0)); } }