コード例 #1
0
ファイル: ctrSender.cs プロジェクト: phinq19/qlcongviec
        private void btnCheck_Click(object sender, EventArgs e)
        {
            SendMail sm = new SendMail(txtSPMT.Text, int.Parse(calPort.EditValue.ToString()), txtUser.Text, txtPass.Text, chkEnableSsl.Checked, int.Parse(calTimeout.EditValue.ToString()));
            if (sm.BeginSendMail(txtFromEmail.Text, txtDislayName.Text, txtFromEmail.Text, "Check Connection From QLCV", "Check Connection From QLCV"))
            {
                MessageBox.Show("Gởi mail test thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            else
            {
                MessageBox.Show("Gởi mail test lỗi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
コード例 #2
0
ファイル: ctrSend.cs プロジェクト: phinq19/qlcongviec
        private void SendMail()
        {
            while (dtTable.Rows.Count > 0)
            {
                if (isAbort == false)
                {
                    string strErr = "";
                    if (isLock == false)
                    {
                        if (dtTable.Rows.Count > 0)
                        {
                            try
                            {
                                isLock = true;
                                long id = long.Parse(dtTable.Rows[0]["ID"].ToString());
                                dtTable.Rows.RemoveAt(0);
                                hashTable.Add(id, false);
                                Customers cus = Customers.Get(id);

                                isLock = false;
                                if (cus != null)
                                {
                                    strErr = "Send to " + cus.LastName + " " + cus.FirstName + "<" + cus.Email +
                                             ">....................";
                                    try
                                    {
                                        string strCt = Content;
                                        strCt = strCt.Replace("[[CallName]]", cus.CallName);
                                        strCt = strCt.Replace("[[LastName]]", cus.LastName);
                                        strCt = strCt.Replace("[[FirstName]]", cus.FirstName);
                                        strCt = strCt.Replace("[[Address]]", cus.Address);
                                        strCt = strCt.Replace("[[Phone]]", cus.Phone);
                                        strCt = strCt.Replace("[[Fax]]", cus.Fax);
                                        strCt = strCt.Replace("[[Email]]", cus.Email);
                                        strCt = strCt.Replace("[[Note]]", cus.Note);
                                        SendMail sm = new SendMail(Sender.Spmt, Sender.Port, Sender.User, Sender.Pass,
                                                                   Sender.EnableSsl,
                                                                   Sender.Timeout);
                                        if (sm.BeginSendMail(Sender.MailFrom, Sender.DislayName, cus.Email, Subject, strCt))
                                        {
                                            //MessageBox.Show("Gởi mail test thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            strErr = strErr + "Successful.";
                                        }
                                        else
                                        {
                                            strErr = strErr + "Error.";
                                            //MessageBox.Show("Gởi mail test lỗi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                        }

                                    }
                                    catch
                                    {
                                        strErr = strErr + "Error.";
                                    }
                                    //progressBarControl1.Increment(1);
                                    DataRow dtRow = dtLogEntries.NewRow();
                                    dtRow["LogEntries"] = strErr;
                                    dtRow["DateTime"] = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
                                    dtLogEntries.Rows.Add(dtRow);
                                    hashTable[id] = true;
                                }
                            }
                            catch
                            {
                                isLock = false;
                            }
                        }
                    }
                }

            }
           
                
        }