日期:2014-05-17  浏览次数:20462 次

.net网站 每天上午8点群发邮件,如何实现,最好是自动的
我这有个网站,要去每天上午8点发邮件,怎么实现每天上午8点自动发送邮件呢

------解决方案--------------------
还么搞定
简单点的话 就直接在Global.asax里面去写
比如:

void Application_Start(object sender, EventArgs e) 
{
   //在应用程序启动时运行的代码
   int seconds = 60;
   aTimer.Elapsed += new ElapsedEventHandler(TimedEvent);
   aTimer.Interval = seconds * 1000;
   aTimer.Enabled = true;
}
void Application_End(object sender, EventArgs e) 
{
   //在应用程序关闭时运行的代码
   //解决应用池回收问题
   System.Threading.Thread.Sleep(5000);
   string strUrl = "";//网站地址
   System.Net.HttpWebRequest _HttpWebRequest =    (System.Net.HttpWebRequest)System.Net.WebRequest.Create(strUrl);
   System.Net.HttpWebResponse _HttpWebResponse = (System.Net.HttpWebResponse)_HttpWebRequest.GetResponse();
   System.IO.Stream _Stream = _HttpWebResponse.GetResponseStream();//得到回写的字节流
   _HttpWebResponse.Close();
}
void TimedEvent(object source, ElapsedEventArgs e)
{
    string appStartTime = ConfigurationManager.AppSettings["StartTime"];//执行时间 比如你这的08:00
    string theNowTime = DateTime.Now.ToString("HH:mm");
    if (theNowTime == appStartTime)
    {
            Method();//这里写你发邮件的方法
     }
}

------解决方案--------------------
https://www.google.com.hk/search?hl=zh-CN&newwindow=1&safe=strict&q=windows+at+%E8%AE%A1%E5%88%92%E4%BB%BB%E5%8A%A1&oq=windows+at+%E8%AE%A1%E5%88%92%E4%BB%BB%E5%8A%A1&gs_l=serp.3..0i8i30.3437.7641.0.7917.7.5.2.0.0.0.231.706.0j4j1.5.0...0.0...1c.1j4.7.serp.oKShwkibSiY