Esempio n. 1
0
 /// <summary>
 /// 得到系统设定的发送邮箱
 /// </summary>
 protected void GetSendMail()
 {
     ShowShop.BLL.SystemInfo.MailSetting bll = new ShowShop.BLL.SystemInfo.MailSetting();
     ShowShop.Model.SystemInfo.MailSetting model = bll.GetModel();
     if (model != null)
     {
         this.txtSendEmail.Text = model.MailId;
     }
 }
Esempio n. 2
0
 private void GetModel()
 {
     ShowShop.BLL.SystemInfo.MailSetting bll = new ShowShop.BLL.SystemInfo.MailSetting();
     Model.SystemInfo.MailSetting model = bll.GetModel();
     if(model!=null)
     {
         this.txtId.Value = model.Id.ToString();
         this.txtMailId.Text = model.MailId;
         this.txtMailPassword.Text = model.MailPassword;
         this.txtSmtpServerIP.Text = model.SmtpServerIP;
         this.txtSmtpServerPort.Text = model.SmtpServerPort.ToString();
     }
     model = null;
     bll = null;
 }
Esempio n. 3
0
 protected void SendByType(string toAddr)
 {
     string server = string.Empty;
     string username = string.Empty;
     string password = string.Empty;
     string title = string.Empty;
     string content = string.Empty;
     ShowShop.BLL.SystemInfo.MailSetting bll = new ShowShop.BLL.SystemInfo.MailSetting();
     ShowShop.Model.SystemInfo.MailSetting model = bll.GetModel();
     if (model != null)
     {
         server = model.SmtpServerIP;
         username = model.MailId;
         password = model.MailPassword;
     }
     title = this.txtEmailTitle.Text.Trim();
     content = this.txtEmailContent.Value;
     SendEmail(server, username, password, toAddr, title, content);
 }
        private void SendEmail(string toaddr, string titel, string body)
        {
            ShowShop.BLL.SystemInfo.MailSetting mailBll = new ShowShop.BLL.SystemInfo.MailSetting();
            ShowShop.Model.SystemInfo.MailSetting mailModel = mailBll.GetModel();
            if (mailModel != null)
            {

                try
                {
                    MailMessage msg = new MailMessage();
                    //发送到
                    msg.To.Add(toaddr);
                    msg.From = new MailAddress(mailModel.MailId, titel, System.Text.Encoding.UTF8);
                    //标题
                    msg.Subject = titel;
                    msg.SubjectEncoding = System.Text.Encoding.UTF8;
                    //内容
                    msg.Body = body;
                    msg.BodyEncoding = System.Text.Encoding.UTF8;
                    msg.IsBodyHtml = true;
                    //优先级
                    msg.Priority = MailPriority.High;
                    SmtpClient client = new SmtpClient();
                    client.Credentials = new System.Net.NetworkCredential(mailModel.MailId, mailModel.MailPassword);
                    //Gmail邮箱发送  587
                    client.Port = 587;
                    client.Host = mailModel.SmtpServerIP;
                    client.EnableSsl = true;
                    client.Send(msg);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }