1. æ·»å Global.asaxæ件
add-->web--> Global Application Class
2. å¨Global.asaxéæ·»å 代ç
protected void Application_Start(object sender, EventArgs e)
{
System.Timers.Timer timer = new System.Timers.Timer(60000);
timer.Elapsed += new System.Timers.ElapsedEventHandler(Send);
timer.Start();
}
public void Send(object sender, System.Timers.ElapsedEventArgs e)
{
if (DateTime.Now.Minute == 20)
{
SendMail sm = new SendMail();
sm.SendEMail("
[email protected]", "
[email protected]", "
[email protected]", "Auto Mail", "This is a auto amil!");
}
}
public void SendEMail(string To1, string CC1, string BC1, string Subject1, string Body1)
{
MailMessage msg = new MailMessage("
[email protected]", To1);
msg.CC.Add(CC1);
msg.Bcc.Add(BC1);
msg.Subject = Subject1;
msg.Body = Body1;
msg.IsBodyHtml = true;
msg.Priority = MailPriority.High;
SmtpClient c = new SmtpClient("127.0.0.1");
c.Port = 25;
c.Send(msg);
}
追é®è½å¦ç¨å¾®ç»ç¹å
³é®æ³¨éï¼
è¿æå°±æ¯æå¨åªå¯ä»¥æ·»å æ¡ä»¶æ§å¶é¡¹ï¼
egï¼ä»æ°æ®åºè·åæ¥æå空é´æå¡å¨æ¥æ对æ¯ï¼å°äºæ个ç¹å®æ¥æ就触åè¿ä¸ªGlobal.asax
谢谢ï¼ï¼