title: what is the cause of SMTP.MAIL: the Operation has timed out?
body: <p>I am creating an intranet web-based application that will send notifications to its users depending on the Admin's choice. </p>
  
  <p><strong>I developed the Mailing page correctly and it work fine with 15 or 20 users. Now, I have more than 200 users, so when I run this page I got the following error and I don't know why:</strong></p>
  
  <blockquote>
    <p>Exception Details: System.Net.Mail.SmtpException: The operation has
    timed out.</p>
  </blockquote>
  
  <p>My Code-Behind (C#):</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {
          SendEmailTOAllUser();
      }
  
  
      protected void SendEmail(string toAddresses, string fromAddress, string MailSubject, string MessageBody, bool isBodyHtml)
      {
          SmtpClient sc = new SmtpClient("MAIL.companyDomainName.com");
          try
          {
              MailMessage msg = new MailMessage();
              msg.From = new MailAddress("pssp@companyDomainName.com", "PMOD Safety Services Portal (PSSP)");
  
              // In case the mail system doesn't like no to recipients. This could be removed
              //msg.To.Add("pssp@companyDomainName.com");
  
              msg.Bcc.Add(toAddresses);
              msg.Subject = MailSubject;
              msg.Body = MessageBody;
              msg.IsBodyHtml = isBodyHtml;
              //Response.Write(msg);
              sc.Send(msg);
          }
          catch (Exception ex)
          {
              throw ex;
          }
  
      }
  
      protected void SendEmailTOAllUser()
  
      {
          string connString = "Data Source=localhost\\sqlexpress;Initial Catalog=psspEmail;Integrated Security=True";
  
          using (SqlConnection conn = new SqlConnection(connString))
          {
              var sbEmailAddresses = new System.Text.StringBuilder(1000);
              string quizid = "";
  
              // Open DB connection.
              conn.Open();
  
              string cmdText = "SELECT MIN (QuizID) As mQuizID FROM dbo.QUIZ WHERE IsSent &lt;&gt; 1";
              using (SqlCommand cmd = new SqlCommand(cmdText, conn))
              {
                  SqlDataReader reader = cmd.ExecuteReader();
                  if (reader != null)
                  {
                      while (reader.Read())
                      {
                          // There is only 1 column, so just retrieve it using the ordinal position
                          quizid = reader["mQuizID"].ToString();
  
                      }
                  }
                  reader.Close();
              }
  
              string cmdText2 = "SELECT Username FROM dbo.employee";
              using (SqlCommand cmd = new SqlCommand(cmdText2, conn))
              {
                  SqlDataReader reader = cmd.ExecuteReader();
                  if (reader != null)
                  {
                      while (reader.Read())
                      {
                          var sName = reader.GetString(0);
                          if (!string.IsNullOrEmpty(sName))
                          {
                              if (sbEmailAddresses.Length != 0)
                              {
                                  sbEmailAddresses.Append(",");
                              }
                              // Just use the ordinal position for the user name since there is only 1 column
                              sbEmailAddresses.Append(sName).Append("@companyDomainName.com");
                          }
                      }
                  }
                  reader.Close();
              }
  
              string cmdText3 = "UPDATE dbo.Quiz SET IsSent = 1 WHERE QuizId = @QuizID";
              using (SqlCommand cmd = new SqlCommand(cmdText3, conn))
              {
                  // Add the parameter to the command
                  var oParameter = cmd.Parameters.Add("@QuizID", SqlDbType.Int);
                  // Get a local copy of the email addresses
                  var sEMailAddresses = sbEmailAddresses.ToString();
  
  
                      string link = "&lt;a href='http://pmv/pssp/StartQuiz.aspx?testid=" + quizid + "'&gt; Click here to participate &lt;/a&gt;";
                      string body = @"Good day, &lt;br /&gt;&lt;br /&gt;
                                  &lt;b&gt; Please participate in the new short safety quiz &lt;/b&gt;"
                                          + link +
                                          @"&lt;br /&gt;&lt;br /&gt;
                              Also, give yourself a chance to gain more safety culture by reading the PMOD Newsletter.
                              &lt;br /&gt; &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;
                              This email was generated using the &lt;a href='http://pmv/pssp/Default.aspx'&gt;PMOD Safety Services Portal (PSSP) &lt;/a&gt;. 
                              Please do not reply to this email.
                              ";
  
                      SendEmail(sEMailAddresses, "", "Notification of New Weekly Safety Quiz", body, true);
  
                      // Update the parameter for the current quiz
                      oParameter.Value = quizid;
                      // And execute the command
                      cmd.ExecuteNonQuery();
              }
              conn.Close();
          }
      }
  </code></pre>
  
  <p><strong>Any help please?</strong></p>