예제 #1
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            if (txtTo.Text.Trim() == "")
            {
                MessageBox.Show("Bạn hãy nhập địa chỉ mail đến!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            #region Mở outlook
            int count = Process.GetProcesses().Where(o => o.ProcessName.Contains("OUTLOOK")).Count();
            if (count == 0)
            {
                try
                {
                    Process.Start("outlook.exe");
                }
                catch (Exception)
                {
                }
            }
            #endregion Mở outlook

            List <string> at = new List <string>();

            if (dtFile.Rows.Count > 0)
            {
                foreach (DataRow row in dtFile.Rows)
                {
                    at.Add(row["Path"].ToString());
                }
            }

            if (txtDetail.Text.Trim() != "")
            {
                txtContent.Text += "<br>"
                                   + "<table style=\"width:100%\" border=\"1\">"
                                   + " <tr>"
                                   + " <td style=\"width:20%\"><b>Mô tả chi tiết</b></td>"
                                   + "<td>" + txtDetail.Text.Trim().Replace("\n", "<br>") + "</td> "
                                   + "</tr>"
                                   + "</table>";
            }

            bool success = TextUtils.SetEmailSendHasAttach(txtSubject.Text.Trim(), txtContent.Text.Trim(), txtTo.Text.Trim(), txtCC.Text.Trim(), at);
            if (success)
            {
                MessageBox.Show("Đã gửi mail thành công!", TextUtils.Caption);
                Description       = txtDetail.Text.Trim();
                this.DialogResult = DialogResult.OK;
                if (IsClosed)
                {
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Gửi không thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
예제 #2
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            if (txtTo.Text.Trim() == "")
            {
                MessageBox.Show("Bạn hãy nhập địa chỉ mail đến!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            #region Mở outlook
            int count = Process.GetProcesses().Where(o => o.ProcessName.Contains("OUTLOOK")).Count();
            if (count == 0)
            {
                try
                {
                    Process.Start("outlook.exe");
                }
                catch (Exception)
                {
                }
            }
            #endregion Mở outlook

            List <string> at = new List <string>();

            if (DtFile.Rows.Count > 0)
            {
                foreach (DataRow row in DtFile.Rows)
                {
                    at.Add(row["Path"].ToString());
                }
            }

            bool success = TextUtils.SetEmailSendHasAttach(txtSubject.Text.Trim(), txtContent.Text.Trim().Replace("\r\n", "<br>"), txtTo.Text.Trim(), txtCC.Text.Trim(), at);

            if (success)
            {
                MessageBox.Show("Đã gửi mail thành công!", TextUtils.Caption);
                IsSent            = true;
                SentTo            = txtTo.Text.Trim();
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("Gửi không thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }