好奇怪的问题,程序第一次运行,系统会自动根据条件发信,再运行就不会发信了,必须把cmd.Parameters.Add("@date",OleDbType.VarChar,10).Value=date;一句改为cmd.Parameters.Add("@date",date);
相反如果用这句运行一次,再运行第二次就又不会发信了,又要再改过来才会发信,调系统日期也不行
我想不会是来回调这两的问题,但不知道问题出在哪,要想运行一次发一次就要来回换这两句,怎么回事,请大家帮忙看看public class Global : System.Web.HttpApplication
{
public Global()
{
InitializeComponent();
} public static string connStr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+HttpContext.Current.Server.MapPath (System.Configuration.ConfigurationSettings.AppSettings ["zkData1"]);
protected void Application_Start(Object sender, EventArgs e)
{
Thread thread = new Thread (new ThreadStart (ThreadFunc)); 

thread.Start (); }
private static void ThreadFunc () 
   

         string date=DateTime.Now.ToString("yyyy-MM-dd");
string strSql="select email from uuuu where dd=@date";
string email;
OleDbConnection conn=new OleDbConnection(connStr);
OleDbCommand cmd=new OleDbCommand(strSql,conn);
cmd.Parameters.Add("@date",OleDbType.VarChar,10).Value=date;
OleDbDataReader sdr;
try
{
conn.Open ();
sdr=cmd.ExecuteReader ();
while(sdr.Read ())
{
email=sdr["email"].ToString();
System.Web.Mail.MailMessage em = new System.Web.Mail.MailMessage();
em.To = email.ToString();
em.From = "[email protected]";
em.Subject ="地圭地地地地";
string MailText = "尊敬的用户,您好!";
MailText+="\n这是最近信息:";

MailText+="\n\n http://www.xxx.com";

em.Body =MailText; //http://SystemWebMail.com (fact 3.8)

em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");   //basic authentication em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "xxxx"); //set your username here em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xxxx"); //set your password here

System.Web.Mail.SmtpMail.SmtpServer = "smtp.tom.com";
System.Web.Mail.SmtpMail.Send(em);


}

}
catch(System.Exception ex)
{
throw new Exception (ex.Message );
}
finally
{
conn.Close ();

   

 
}