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); }
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); }