Exemple #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);
        }
Exemple #2
0
        /// <summary>
        /// 获取内置的邮件账户
        /// </summary>
        /// <returns></returns>
        public static St.Mail.StMail GetMailAcc(string displayName)
        {
            string configFile = Environment.CurrentDirectory + "\\config\\config.ini";
            StMail mail       = new StMail("*****@*****.**", "altntlmjsnikicig", displayName);

            if (System.IO.File.Exists(configFile))
            {
                string[] line = StFile.ReadFileLines(configFile).ToArray();
                if (line[0] == "1")
                {
                    mail = new StMail("*****@*****.**", line[1], displayName);
                }
                else if (line[0] == "2")
                {
                    mail = new StMail("*****@*****.**", line[2], displayName);
                }
            }
            return(mail);
        }
Exemple #3
0
        public void SendMail2()
        {
            string nicheng = this.textBox4.Text;
            string mailTo  = this.textBox2.Text;
            string content = this.textBox3.Text.Replace("\r\n", "<br />");

            StMail mail = Pub.GetMailAcc("来自远方的祝福");

            Account to = new Account()
            {
                Address = mailTo, Name = nicheng, IsSSL = true, IsBodyHtml = true
            };

            //Account to = new Account() { Address = "*****@*****.**", IsSSL = true, IsBodyHtml = true };
            SetControlValue(this.label4, "准备发送...");
            bool rel = mail.Send(to, "生日快乐", content);

            SetControlValue(this.label4, string.IsNullOrWhiteSpace(mail.ErroMsg) ? "发送成功" : mail.ErroMsg);
        }