sql - C# email alert not picking up new code -


i have following code sending email alert around 60 users when extract gets uploaded. strange happening, sending previous query results not new ones. difference quantity of users before sending few people sending larger quantity. on code larger quantity application seems not see has changed , sends previous users. cached query or something. don't know whats going on. when change 1 email address works fine , picks changes.

  if (session["extractno"].tostring() == "extract 1")             {                 //connection string (sendemail)                 string sendemail = configurationmanager.connectionstrings["sendemail"].connectionstring;                  sqldatareader reader;                 string sendmessage = "select name, position, email authorisedstaff position = 'cm' or position = 'dhod' or position = 'hod'"; //<---- change position before launch                  using (sqlconnection myconnection = new sqlconnection(sendemail))                 {                     myconnection.open();                     sqlcommand mycommand = new sqlcommand(sendmessage, myconnection);                      arraylist emailarray = new arraylist();                     reader = mycommand.executereader();                      var emails = new list<emailcode>();                      while (reader.read())                     {                         emails.add(new emailcode                         {                             email = convert.tostring(reader["email"]),                             name = convert.tostring(reader["name"]),                             position = convert.tostring(reader["position"])                         });                     }                      foreach (emailcode email in emails)                     {                         //email config                          const string username = "roll@test.co.uk"; //account address                         const string password = "######"; //account password                          smtpclient smtpclient = new smtpclient();                         mailmessage mail = new mailmessage();                         mailaddress fromaddress = new mailaddress("roll@test.co.uk", "ptlp"); //address , name                          smtpclient.host = "omavex11";  //host name particular email address                         smtpclient.port = 25; //port number particular email address                          mail.from = fromaddress;                         mail.to.add(email.email);                         mail.subject = ("ptlp check");                          mail.isbodyhtml = true;                          //change context of message below appropriate                         mail.body = httputility.htmlencode(email.name) + " <br /> <p>part time lecturer payroll details available checking.  if changes need made please notify mis possible. </p> <p>please ensure adjustments have been submitted.  adjustments not submitted on time paid following month. </p>    ";                           //smtpclient.enablessl = true;                         smtpclient.deliverymethod = smtpdeliverymethod.network;                         smtpclient.credentials = new system.net.networkcredential(username, password);                          smtpclient.send(mail);                      }                 }              } 

try clearing list first before adding new items/objects assume this

var emails = new list<emailcode>(); 

is list.


Comments