He probado con este código pero ningún candidato recibe los avisos:
Código PHP:
private void envioMasivo()
{
string message = "<body>" +
"<font><b><i>\"" + this.txtNomEmp.Text + "\"</i></b> " +
"ofrece el puesto de <b><i>\"" +
this.txtPuesto.Text + "\"</i></b><br>. " +
"<a href='http://miportaldeempleo.com/Oferta.aspx?id_oferta=" + id_oferta + "'" +
"'>Ver oferta/a></font>" +
"</body>";
string strCon = ConfigurationSettings.AppSettings["constring"];
con = new SqlConnection(strCon);
string strSql = "SELECT mail FROM candidatos";
SqlCommand cmd = new SqlCommand(strSql,con);
SqlDataReader r = cmd.ExecuteReader();
DateTime inicio = new DateTime();
inicio = DateTime.Now;
TimeSpan resta = new TimeSpan();
int numEnvios = 0;
int numMaxEnvios = 150;
while(r.Read())
{
Cartero.Mensaje mail = new Cartero.Mensaje();
mail.Hacia = r.GetValue(0).ToString();
mail.Titulo = "¡¡Nueva oferta!!";
mail.Cuerpo = message;
try
{
mail.enviar();
}
catch {} //No hacemos nada si falla
resta = DateTime.Now.Subtract(inicio);
numEnvios += 1;
if(numEnvios > numMaxEnvios)
{
while(resta.Seconds < 60)
{
Thread.Sleep(1000);
resta = DateTime.Now.Subtract(inicio);
}
numEnvios = 0;
inicio = DateTime.Now;
}
}
r.Close();
cmd.Dispose();
}
¿Veis algún fallo?