title: How can I send email to multiple recipients from SQL Server database in ASP.NET MVC?
body: <p>I want to send email to multiple recipients. I retrieve the email addresses of multiple users from a SQL Server database, like this:</p>
  
  <pre><code>var students = (from u in db.Users
                  where u.projectGroup == id
                  select u.userEmail).ToArray();
  </code></pre>
  
  <p>This will return multiple email addresses like: <code>user1@gmail.com user2@gmail.com</code>
  and I try to send to multiple users like this</p>
  
  <pre><code>for (int h = 0; h &lt; students.Length; h++)
  {
      try
      {
          var body = "&lt;p&gt;Email From: {0} ({1})&lt;/p&gt;&lt;p&gt;Message:&lt;/p&gt;&lt;p&gt;{2}&lt;/p&gt;";
          var smtpClient = new SmtpClient();
  
          var message = new MailMessage();
          message.To.Add(new MailAddress(students[h])); 
          message.Subject = "I'm interested in your project";
          message.Body = string.Format(body, model.FromName, model.FromEmail, model.Message);
          message.IsBodyHtml = true;
  
          using (var smtp = new SmtpClient())
          {
              await smtp.SendMailAsync(message);
              return RedirectToAction("Sent");
          }
      }
      catch (Exception ex)
      {
          //MessageBox("Your Email address is not valid");
          //ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Your Email address is not valid');", true);
      }
  }
  </code></pre>
  
  <p>but this did not work, it sends an email to first user but another user did not receive the email.</p>
  
  <p>How can I split each email in a one row to send an email to multiple recipients?</p>