예제 #1
0
        public void SendMail1()
        {
            StChineseCalendar dat    = new StChineseCalendar(DateTime.Now);
            string            nowDay = dat.GanZhiYearString + dat.ChineseMonthString + dat.ChineseDayString + "日";
            DateTime          dt1    = new DateTime(2014, 11, 21);
            DateTime          dt2    = DateTime.Now;
            //dt2 = new DateTime(2016, 11, 21);
            //邮件内容
            string ya          = string.IsNullOrWhiteSpace(dat.DateHoliday) ? "" : "(" + dat.DateHoliday + ")";
            string yi          = string.IsNullOrWhiteSpace(dat.ChineseCalendarHoliday) ? "" : " " + dat.ChineseCalendarHoliday + "";
            string w           = string.IsNullOrWhiteSpace(dat.WeekDayHoliday) ? "" : "(" + dat.WeekDayHoliday + ")";
            string SendContent = "亲爱的bd,今天是" + DateTime.Now.ToString("yyyy年MM月dd日") + ya + "(农历:" + nowDay + yi + ")" + w
                                 + ",庆祝我俩相爱 <span style='color:red;'>" + StDate.GetDateTimeSpanString(dt1, dt2) + "</span>";


            StMail mail = Pub.GetMailAcc("你家的sg");

            Account to = new Account()
            {
                Address = this.textBox1.Text, IsSSL = true, IsBodyHtml = true
            };

            //Account to = new Account() { Address = "*****@*****.**", IsSSL = true, IsBodyHtml = true };
            SetControlValue(this.label2, "准备发送...");
            bool rel = mail.Send(to, "sg的致电", SendContent);

            SetControlValue(this.label2, string.IsNullOrWhiteSpace(mail.ErroMsg) ? "发送成功" : mail.ErroMsg);
        }
예제 #2
0
        private void Re()
        {
            this.label1.Text = "";
            DateTime dt1 = new DateTime(2014, 11, 21);
            DateTime dt2 = DateTime.Now;

            this.label1.Text += "今天是:" + dt2.ToString("yyyy-MM-dd HH:mm:ss");
            this.label1.Text += "\r\n" + dt1.ToString("yyyy-MM-dd HH:mm:ss") + "距离现在";
            this.label1.Text += "\r\n" + StDate.GetDateTimeSpanString(dt1, dt2) + "或者";
            this.label1.Text += "\r\n" + (int)((dt2 - dt1).TotalSeconds) + "秒";
        }