Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send a mail to more than 15000 recipient?

We are using asp.net 3.5 with c#.We have to make an powerful mailer module.This module can mail more than 15000 recipient or in short all records in DBMS.I would like to ask few things.

1)We have a code which sends a mail to single recipient.How will we send a mail to multiple recipient.I tried with our code to add more than one email id by ',' but it sends only first email id.Here is the code sample

 public bool Mail(string to, string subject, string body)
        {
            try
            {

                MailMessage objEmail = new MailMessage();
                objEmail.To =to;
                objEmail.From = "[email protected]";
                //objEmail.Priority =priority

                objEmail.Subject = subject;

                objEmail.Body = body;

                //enable the Html tag...

                objEmail.BodyFormat = MailFormat.Html;
                objEmail.Priority = MailPriority.High;

                SmtpMail.SmtpServer = "localhost";

                try
                {
                    SmtpMail.Send(objEmail);
                    return true;

                }
                catch(Exception ex)
                {
                    string error = ex.StackTrace;
                    return false;
                }
            }
            catch
            {
                return false;
            }
        }

2)What is the max limit to send mail at a time.Means how much value we can assign in string to that contains emailids?

3)One main thing our code is in button click so if we have more than 15000 records so will it able to send to mail all because What we are thinking is that page will have 60sec to render so it may send mails only those ids cover in 60 sec.

Lets suggest what is the best way to do that.

Thanks in advance.

like image 962
PrateekSaluja Avatar asked May 28 '11 07:05

PrateekSaluja


People also ask

How to send an email to multiple recipients?

Personalized Mail Merge Method: The most effective way of sending an email to multiple recipients is to use mail merge method. In this blog, we are using SalesHandy to create a personalized mail merge campaign.

Will the email be delivered to all 100 recipients?

However, the email will be delivered to all 100 recipients. Your Google account has an upper limit of 3,000 external addresses per day, so this method would work only if you stay under that limit when adding all group members together.

How many emails can you send in a bulk email?

But if you’re sending a bulk email campaign on behalf of your company, and you have a large customer or prospect list, that 2,000-email sending limit won’t meet your needs. That’s because, like to the individual account, one email addressed to 5,000 recipients, it counts as 5,000 emails.

How many emails can I send from my Hotmail account?

The Hotmail limit for outgoing email messages is 300 (three hundred) messages per day. Maximum 100 per email. You can add up to 100 (one hundred) recipients per message in Windows Live Hotmail. Again, suspicious activity can lead to a temporarily lower limit (as low as 10 (ten) recipients).


2 Answers

Do not use System.Web.Mail. Use System.Net.Mail. See this blog.

System.Web.Mail is deprecated and not recommended.

You need to pass the work onto an actual mail server/service. A third party one is your best option. Do not send email directly from the web application code as request timeouts, authentication timeouts, etc will eventually halt your send loop. Also, this process will lock up the current page/session until it is done/halted and I have also experienced entire applications locking up for ALL visitors when pages are executing heavy tasks like this.

If all you want is a cheap email server that you can add emails to a queue and the server will just chug through them and send them, then Amazon SES is worth a look. If you want more user management and campaign management tools, then MailChimp or JangoMail might be your best options.

Amazon SES is definitely the cheapest as you only pay for what you use. I spend 4 bucks a month on average.

All of these provide APIs you can use in your code.

Aside: Do ensure that your recipients have somehow requested or are otherwise expecting these emails. Sending spam is illegal and the punishment is harsh.

Resources

Please also check out these questions:

  • How do you send mass emails from ASP.NET?
  • How to send 100,000 emails weekly?
like image 86
Chev Avatar answered Oct 21 '22 09:10

Chev


Apart from Chevex answer: If you send an email to multiple recipients then consider using BCC. If you use TO and CC each recipient will see the email addresses of the other recipients which they might not appreciate.

If you want to roll your own mail sendig module instead of using one of the available services then have a look at this question for some approaches of how to run longer lived background tasks in ASP.NET: Best way to run a background task in ASP.Net web app and also get feedback?

like image 42
ChrisWue Avatar answered Oct 21 '22 09:10

ChrisWue