Link to home
Start Free TrialLog in
Avatar of Argblat
Argblat

asked on

Bulk Emails w/ SMTP & Performance

While I have built numerous applications for the company I work for that make use of System.Web.Mail and the SMTP server to send emails right from the application, this is the first time I've ever built such a system that has the potential to send hundreds of emails out with the click of a button.  

In past projects I have built my email code like such:

MailMessage Message = new MailMessage();
Message.From = "test@test.com";
Message.To = strTo;
Message.Subject = strSubj;
Message.Body = strBody;
SmtpMail.SmtpServer = "192.168.12.22";
SmtpMail.Send(Message);

In testing this system for the new, bulk email application, its causing spikes with only ten emails ... I have a good feeling hundreds of emails are going to cause mucho problemos

Can someone smarter than me regarding this please explain to me a way to handle this properly?

I would also like to take the time to note that this application is NOT going to be used for spam (...per se...).  I work for a company with thousands of clients who sometimes, in large groups, need to be notified of changes to the services we offer.  This application is meant to replace a very labor intensive method we currently have in place.

Thank you

Avatar of Argblat
Argblat

ASKER

I always forget to mention this part:
ASP.NET v1.1
Visual Studio 2003
C#
The best idea is to break down how many e-mails are sent at one time (multiple To's CC's and BCC's). the best thing to do is send X at a time, then do a thread.sleep for a tenth of a second, and send the next batch. This way the SMTP doesn't get bogged down, and doesn't block you out.
Queue up the email details in a database, and have a scheduled job come by afterward and run a program to send them where you won't have to worry about page timeouts and what not.
Avatar of Argblat

ASKER

@strickdd:

I'm curious about your solution.  Have you used it yourself?  I have no experience with Thread.Sleep ... I just stumbled across this: http://www.quiksoft.com/freesmtp/ and I'm wondering if their feature "Message queuing" (http://www.quiksoft.com/emdotnet/comparison.aspx) works on the same principle ... or if there is more to it than that

@raterus

The user is expecting that when they click the 'Submit' button that the emails are sent ... Unless I can't find an in-code runtime solution to sending the mass emails, I would prefer to avoid adding all those extra steps to the process (writing to the db, running a scheduled job, etc)

thank you both for your feedback....
Keep it coming!
ASKER CERTIFIED SOLUTION
Avatar of strickdd
strickdd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Argblat,

If you're not opposed to 3rd party controls (which you shouldn't be unless you have all the time in the world to build everything yourself), let me highlight a great provider for this type of thing. Advanced Intellect makes a product called AspNetEmail (http://www.aspnetemail.com/) and it has great support for sending bulk email. In fact, there is an online demo (with code) showing you how to send bulk email:

http://www.aspnetemail.com/samples/webmailer/

Some of the code is specific to their product, but many of the concepts used in their "webmailer" could be adapted for use with the standard .Net mail components. In any event, I've used Advanced Intellect for years and their service and features are great for sending email in ASP.NET applications.

Thanks~
Todd