How do you send mass emails from ASP.NET?

I built a website for a client and they would like a custom newsletter tool. Building the tool was easy, but I'm not sure how to send the email.

I set up a test page and managed to send a test email to myself using the System.Net.Mail namespace. I tried applying this code to a loop on the newsletter page, but it's turning out to be quite a difficult task. The email sending loop locks up the whole site for about an hour while it sends its emails. Sometimes it will abort the loop midway and some of the emails won't get sent.

I tried starting the loop on another thread.

protected void btnSendNewsletter_Click(object sender, EventArgs e)
{
    Thread t = new System.Threading.Thread(new ThreadStart(SendEmails));
    t.Start();
}

but this still makes the site go slow and also has a habit of aborting part way through. What is the common method for sending mass emails? I'm sure I'm not doing it right.

I am very new to the email arena in .NET.

7
задан halfer 25 October 2019 в 06:29
поделиться