title: smtp is not working on for loops
body: <p>I want to send an email to more than 2 people using my own database. So I use for loop to send an email. And it is sent well to a first person(mail_data.Rows[0][0]), but not for the second person.(mail_data.Rows[1][0]) The code stops before smtp.Send(mm). Second person's email is exactly correct. I have no idea why the code stops there.</p>
  
  <pre><code>    private void Email()
      {
          //get the data from database
          DataTable data = GetData();
          DataTable email_data = GetEmailData();
  
          data.TableName = "Employee_Data";
  
                   ....
  
  
                  String from = "aa@gmail.com";
  
                  for (int i = 0; i &lt;= email_data.Rows.Count; i++)
                  {
                      String to = email_data.Rows[i][0].ToString();
  
                      using (MailMessage mm = new MailMessage(from, to))
                      {
                          this.WriteToFile(to);
                          using (SmtpClient smtp = new SmtpClient())
                          {
  
                              mm.Subject = "Fresh NSO Updated List";
  
                              mm.AlternateViews.Add(body);
                              mm.Attachments.Add(new Attachment(new MemoryStream(bytes), "NSOList.xlsx"));
                              mm.IsBodyHtml = true;
  
                              smtp.Host = "smtp.gmail.com";
                              smtp.EnableSsl = true;
                              System.Net.NetworkCredential credentials = new System.Net.NetworkCredential();
                              credentials.UserName = "aa@gmail.com";
                              credentials.Password = "aa";
                              smtp.UseDefaultCredentials = true;
                              smtp.Credentials = credentials;
                              smtp.Port = 587;
  
                              this.WriteToFile("beforeSend");
                              Thread.Sleep(1000);
            //just stop here on second loop, 
                              smtp.Send(mm);
                              this.WriteToFile("Sent!");
                          }
  
                      }
  
                  }
              }
  </code></pre>