/// <summary> /// 发送邮件 /// </summary> /// <returns></returns> bool SendEmail(string password, string mailTo) { //string url = string.Format("{0}RegisterConfirm.aspx?uid={1}&v={2}", Pinsou.Config.SystemConfig.SysURL, uid, code); MLMGC.Controls.SendMail sm = new MLMGC.Controls.SendMail(); string mailbody = string.Format("<p style=\"font-size:14px;font-weight:700;\">您的密码是:{0}</p>", password); string errorMessage; bool flag = sm.Send(mailTo, "名录宝找回密码", mailbody, out errorMessage); return(flag); }
/// <summary> /// 发送邮件 /// </summary> /// <returns></returns> bool SendEmail(string gid, string emailCode, string mailTo) { //string url = string.Format("{0}RegisterConfirm.aspx?uid={1}&v={2}", Pinsou.Config.SystemConfig.SysURL, uid, code); MLMGC.Controls.SendMail sm = new MLMGC.Controls.SendMail(); string path = Config.RootURL + string.Format("/User/regstep2.aspx?gid={0}&email={1}&code={2}", gid, HttpContext.Current.Server.UrlEncode(mailTo), emailCode); string mailbody = string.Format("<p style=\"font-size:14px;font-weight:700;\">请复制该验证码:{0},完成邮箱验证,以便您在名录宝能顺利进行注册。</p><p style=\"font-size:14px;font-weight:700;\">或者点击这里:<a href='{1}'>继续</a></p>", emailCode, path); string errorMessage; bool flag = sm.Send(mailTo, "来自名录宝的验证邮件测试邮件", mailbody, out errorMessage); return(flag); }
protected void btnSend_Click(object sender, EventArgs e) { if (data == null) { Jscript.ShowMsg("读取配置失败", this); return; } MLMGC.Controls.SendMail SM = new MLMGC.Controls.SendMail(data.Email, data.SMTP, data.Port, data.UserName, data.Password, data.UserName); string errorMessage; bool b = SM.Send(txtReceiveEmail.Text.Trim(), txtSubject.Text.Trim(), txtContent.Text.Trim(), out errorMessage); Jscript.ShowMsg("发送" + (b?"成功":"失败" + errorMessage), this); }
protected void btnSend_Click(object sender, EventArgs e) { //验证数据是否正确 string email = txtReceiveEmail.Text.Trim(); string subject = txtSubject.Text.Trim(); string content = txtContent.Text.Trim(); //if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(subject)) //{ // Jscript.ShowMsg("请", this); //} //显示邮件配置信息 E_MailConfig data = new T_MailConfig().GetConfig(new E_MailConfig() { EnterpriseID = base.EnterpriceID, UserID = UserID }); if (data == null) { Jscript.ShowMsg("读取配置失败", this); return; } //处理附件地址 string[] listAtt = hdAttachment.Value.Split(','); for (int i = 0; i < listAtt.Length; i++) { listAtt[i] = MLMGC.COMP.Config.GetEnterpriseM(EnterpriceID, listAtt[i]); } MLMGC.Controls.SendMail SM = new MLMGC.Controls.SendMail(data.Email, data.SMTP, data.Port, data.UserName, data.Password, data.Name, listAtt.ToList()); string errorMessage = string.Empty; string[] eArray = email.Split(','); bool flag = true; foreach (string s in eArray) { flag = flag && SM.Send(s, subject, content, out errorMessage); } //添加操作日志 new MLMGC.BLL.Enterprise.T_Log().Add(new MLMGC.DataEntity.Enterprise.E_Log() { EnterpriseID = EnterpriceID, UserID = UserID, LogTitle = "发送电子邮件", IP = MLMGC.COMP.Requests.GetRealIP() }); Jscript.ShowMsg("发送" + (flag ? "成功" : "失败" + errorMessage), this); }