I have a DataReader that displays each email that it sends it off to (for confirmation purposes) and it looks like it did went off, but no one has received it. I believe I have good exception handling implemented as shown below:
public void Send_Mail(Object sender, System.Web.UI.ImageClickEventArgs e)
{SqlConnection conn = new SqlConnection("my connection string");
SqlCommand comm = new SqlCommand("my SQL statement, conn);
SqlDataReader dr;MailMessage mailer = new MailMessage();
mailer.From = txtFrom.Text.Trim();
mailer.Subject = txtSubject.Text.Trim();
mailer.Body = txtBody.Text.Trim();
mailer.BodyFormat = MailFormat.Html;try
{
conn.Open();
dr = comm.ExecuteReader(CommandBehavior.CloseConnection);
while(dr.Read())
{
mailer.To = dr[0].ToString();
lblConfirmation.Text = dr[0].ToString();
SmtpMail.SmtpServer = "xx.xx.xx.xxx";
SmtpMail.Send(mailer);
}
dr.Close();lblConfirmation.Text = "Your message was successfully sent to the following recipients:" ;
conn.Open();
dgrid.DataSource = comm.ExecuteReader(CommandBehavior.CloseConnection);
dgrid.DataBind();
dr.Close();
}
catch(SqlException ex)
{
Response.Write("A database-related exception occurred!<br>" + ex.ToString());
}
catch(Exception ex)
{
Response.Write("A general exception occurred!<br>" + ex.ToString());
}
finally
{
if(conn.State == ConnectionState.Open)
{
conn.Close();
}
}
}
Everything seems the same as with 100 emails as with 3,800 emails, but can't seem to know where my emails went. I did go to (C:\inetput\mailroot) but couldn't find anything near my situation.
Could someone please help me out here? Is there a queue somewhere I don't know about? ASP.NET can handle this type of mass mailings correct?
Any advice will be greatly appreciated.OK, I just learned that the Exchange Server our corporation goes off of DOES NOT allow emailing over 200 users. Ahh, at least I know one part of my problem.
Now, to go around this constraint, I was thinking of setting up a loop and sending emails in chunks of 100 or so and separated by say 5 minutes. Is this good practice? I would like know what everyone else is doing?
Also, I noticed a thread a few months back here (I believe) that someone was attempting something very similar to my situation, but I can't seem to locate that thread anymore. Anyone know what I am talking about?
Your assistance will be greatly appreciated!
0 comments:
Post a Comment