刚才在博客园发表了一篇文章,题目为
[ 使用MailMessage和SmtpClient类实现asp.net的邮箱发送,文章地址:http://www.cnblogs.com/gossip/archive/2010/03/23/1692639.html]
有同学说太过简单,不便于发到首页,所以我又移到了候选页。后来继续研究了下,想实现定时发送邮件功能,没想到竟然发现发送垃圾邮件的方法。
功能很简单,仅供娱乐。原理就是在Global.asax中开启一个现成,每隔一段时间就向指定邮箱发送邮件,具体发送代码见上篇文章。线程代码如下:
代码
void Application_Start(object sender, EventArgs e)
{
thread = new System.Threading.Thread(new System.Threading.ThreadStart(WriteLog));
thread.Start();
}
System.Threading.Thread thread;
void WriteLog()
{
while (true)
{
SendEmail(); //发送
System.Threading.Thread.CurrentThread.Join(5000);//阻止五秒
}
}
{
thread = new System.Threading.Thread(new System.Threading.ThreadStart(WriteLog));
thread.Start();
}
System.Threading.Thread thread;
void WriteLog()
{
while (true)
{
SendEmail(); //发送
System.Threading.Thread.CurrentThread.Join(5000);//阻止五秒
}
}