We are interested in implementing something into our ASP.NET web application that will send out an e-mail to addresses pulled from SQL Server 2008.
This doesn't seem like it would be that difficult. Pseudo-code:
EmailAddressList addresses = EmailAddressManager.GetList();
foreach (EmailAddress x in addresses)
{
MailMessage msg = new MailMessage("fromaddress@test.com", x.ToAddress);
//prepare msg, body, subject, etc.
SmtpClient smtp = new SmtpClient();
smtp.Send(msg);
//add artificial delay for throttling? this seems to be a common tactic
}
This question has an upvoted comment that links to something that was supposedly helpful, but now just leads to a Page Not Found error.
And in this question, the OP says specifically that the above pseudo-code method isn't "the good way." But what is wrong with it? Is there a common or better practice for this? Are there hidden pitfalls I'm not taking into account?
And just a little bit more detail about our situation: this will only be used maybe twice per month, and the number of emails to be sent at once will not be above roughly 30 or 40. The end goal is, we go to this page that has this tool, we can preview what's going to get sent out and to who, and then we just press a button and it executes the above pseudo-code.