예제 #1
0
        private void sendemail(string mailfrom, string frompassword, string mailto, string flag, string hospitalname)
        {
            StringBuilder sb1  = new StringBuilder();
            StringBuilder sb2  = new StringBuilder();
            StringBuilder sb11 = new StringBuilder();
            StringBuilder sb22 = new StringBuilder();

            sb1.Append(hospitalname + "<br>");
            sb2.Append(hospitalname + "<br>");
            sb11.Append(hospitalname + "<br>");
            sb22.Append(hospitalname + "<br>");
            bool      needSend  = false;
            bool      needSend2 = false;
            string    sql       = "select * from Status_Now";
            DataTable dt        = tool.DbToDatatable(sql);

            for (int i = 0; i < 10; i++)
            {
                if (dt.Rows[i][4].ToString() == "E")
                {
                    needSend2 = true;
                    sb1.Append(dt.Rows[i][6].ToString() + " || " + dt.Rows[i][7].ToString() + " || " + dt.Rows[i][8].ToString() + "<br>");
                    sb11.Append(dt.Rows[i][7].ToString() + " || " + dt.Rows[i][8].ToString() + "<br>");
                }
                if (dt.Rows[i][4].ToString() == "W")
                {
                    needSend = true;
                    sb2.Append(dt.Rows[i][6].ToString() + " || " + dt.Rows[i][7].ToString() + " || " + dt.Rows[i][8].ToString() + "<br>");
                    sb22.Append(dt.Rows[i][7].ToString() + " || " + dt.Rows[i][8].ToString() + "<br>");
                }
            }
            string mailBody = "";

            if (flag == "warn" && needSend == true && oldsb2 != sb22.ToString())
            {
                mailBody = sb2.ToString();
                Class.SendMail sendMail = new Class.SendMail();
                sendMail.mailPwd  = frompassword;
                sendMail.sendFrom = mailfrom;
                sendMail.sendTo   = mailto;
                sendMail.subject  = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + " IT3000警告信息";
                sendMail.mailBody = mailBody;
                sendMail.send();
                oldsb2 = sb22.ToString();
            }
            if (flag == "error" && needSend2 == true && oldsb1 != sb11.ToString())
            {
                mailBody = sb1.ToString();
                Class.SendMail sendMail = new Class.SendMail();
                sendMail.mailPwd  = frompassword;
                sendMail.sendFrom = mailfrom;
                sendMail.sendTo   = mailto;
                sendMail.subject  = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + "IT3000错误信息";
                sendMail.mailBody = mailBody;
                sendMail.send();
                oldsb1 = sb11.ToString();
            }
        }
예제 #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     string mailBody = "测试邮件发送成功!";
     Class.SendMail sendMail = new Class.SendMail();
     sendMail.mailPwd = "zhouweicheng";
     sendMail.sendFrom = "*****@*****.**";
     sendMail.sendTo = textBox1.Text;
     sendMail.subject = "测试邮件发送成功!";
     sendMail.mailBody = mailBody;
     sendMail.send();
     MessageBox.Show("邮件发送成功");
 }
예제 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string mailBody = "测试邮件发送成功!";

            Class.SendMail sendMail = new Class.SendMail();
            sendMail.mailPwd  = "zhouweicheng";
            sendMail.sendFrom = "*****@*****.**";
            sendMail.sendTo   = textBox1.Text;
            sendMail.subject  = "测试邮件发送成功!";
            sendMail.mailBody = mailBody;
            sendMail.send();
            MessageBox.Show("邮件发送成功");
        }
예제 #4
0
        private void sendemail(string mailfrom, string frompassword, string mailto, string flag, string hospitalname)
        {
            StringBuilder sb1 = new StringBuilder();
            StringBuilder sb2 = new StringBuilder();
            StringBuilder sb11 = new StringBuilder();
            StringBuilder sb22 = new StringBuilder();
            sb1.Append(hospitalname + "<br>");
            sb2.Append(hospitalname + "<br>");
            sb11.Append(hospitalname + "<br>");
            sb22.Append(hospitalname + "<br>");
            bool needSend = false;
            bool needSend2 = false;
            string sql = "select * from Status_Now";
            DataTable dt = tool.DbToDatatable(sql);
            for (int i = 0; i < 10; i++)
            {
                if (dt.Rows[i][4].ToString() == "E")
                {
                    needSend2 = true;
                    sb1.Append(dt.Rows[i][6].ToString() + " || " + dt.Rows[i][7].ToString() + " || " + dt.Rows[i][8].ToString() + "<br>");
                    sb11.Append(dt.Rows[i][7].ToString() + " || " + dt.Rows[i][8].ToString() + "<br>");

                }
                if (dt.Rows[i][4].ToString() == "W")
                {
                    needSend = true;
                    sb2.Append(dt.Rows[i][6].ToString() + " || " + dt.Rows[i][7].ToString() + " || " + dt.Rows[i][8].ToString() + "<br>");
                    sb22.Append(dt.Rows[i][7].ToString() + " || " + dt.Rows[i][8].ToString() + "<br>");

                }

            }
            string mailBody = "";
            if (flag == "warn" && needSend == true && oldsb2 != sb22.ToString())
            {
                mailBody = sb2.ToString();
                Class.SendMail sendMail = new Class.SendMail();
                sendMail.mailPwd = frompassword;
                sendMail.sendFrom = mailfrom;
                sendMail.sendTo = mailto;
                sendMail.subject = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + " IT3000警告信息";
                sendMail.mailBody = mailBody;
                sendMail.send();
                oldsb2 = sb22.ToString();
            }
            if (flag == "error" && needSend2 == true && oldsb1 != sb11.ToString())
            {
                mailBody = sb1.ToString();
                Class.SendMail sendMail = new Class.SendMail();
                sendMail.mailPwd = frompassword;
                sendMail.sendFrom = mailfrom;
                sendMail.sendTo = mailto;
                sendMail.subject = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + "IT3000错误信息";
                sendMail.mailBody = mailBody;
                sendMail.send();
                oldsb1 = sb11.ToString();
            }
        }