private void btnGuiMail_Click(object sender, EventArgs e) { try { ValidateEmailKhiGui(); int _CauHinhId = O2S_Common.TypeConvert.Parse.ToInt32(cboEmailGui.SelectedValue.ToString()); CAUHINHEMAIL _cauhinh = CauHinhEmailLogic.SelectSingle(_CauHinhId); if (_cauhinh == null) { O2S_Common.Utilities.ThongBao.frmThongBao _frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.VUI_LONG_NHAP_DAY_DU_THONG_TIN); _frmthongbao.Show(); return; } SmtpClient mailclient = new SmtpClient(_cauhinh.SMTPServer, _cauhinh.Port ?? 0); mailclient.EnableSsl = true; mailclient.Credentials = new NetworkCredential(_cauhinh.TaiKhoan, O2S_Common.EncryptAndDecrypt.MD5EncryptAndDecrypt.Decrypt(_cauhinh.MatKhau, true)); MailMessage message = new MailMessage(_cauhinh.TaiKhoan, txtEmailNhan.Text); message.Subject = txtTieuDeMail.Text; message.Body = txtNoiDungMail.HtmlText; message.IsBodyHtml = true; mailclient.Send(message); MessageBox.Show(Base.ThongBaoLable.GUI_MAIL_THANH_CONG, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); //O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.GUI_MAIL_THANH_CONG); //frmthongbao.Show(); } catch (ArgumentException ex) { MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (Exception ex) { MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning); O2S_Common.Logging.LogSystem.Error(ex); //O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.GUI_MAIL_THAT_BAI); //frmthongbao.Show(); } }
private void gridViewCauHinhEmail_Click(object sender, EventArgs e) { try { if (gridViewEmail.RowCount > 0) { var rowHandle = gridViewEmail.FocusedRowHandle; int _CauHinhEmailId = O2S_Common.TypeConvert.Parse.ToInt32(gridViewEmail.GetRowCellValue(rowHandle, "CauHinhEmailId").ToString()); this.CauHinhEmailSelect = CauHinhEmailLogic.SelectSingle(_CauHinhEmailId); if (this.CauHinhEmailSelect != null) { CauHinhEmail_ClickData(this.CauHinhEmailSelect); LockAndUnLookPanelControl(false); } } } catch (Exception ex) { O2S_Common.Logging.LogSystem.Warn(ex); } }