Email solution independent from web site

Hi,

I have a fairly big web site that might be sending hundreds of emails on one go, basically i want to create a independent tool to send these emails, I want it independent because it will be used by the main site (ASP) and by a web service (.net), and also because i don't want the web site to crash if some problem happens with sending the email, so i don't want it IIS managed!. I was thinking on a Console application (.net) but i don't know if ASP would be able to use it! I'm open to any suggestion as long as they are appropriate. Technically the tool should load the data from a database and send the emails on a queue (is this the SMTPs job or should it be the tool?).

Thnks for your help

Regards,
LVL 3
JunkManAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fernandonajeraCommented:
If I've read your question right, you want some kind of batch send mail. This is one approach.

First of all, create a table in your DB with basic fields: from, to, cc, bcc, subject, message and maybe attachments (that can be a little more complicate, but is doable). Even a priority field could be valuable (to send the signup emails earlier than the regular mailling list emails, for instance). Also include a status field: not-sent, sent, failed. Maybe a datestamp field to know when you sent it. You know.

In your ASP page, insert into that table any email you want to send. Then say to the customer something like "you're emails are going to be send in the next few minutes.".

Then, write a Windows Service (in .NET if you want to). Place parameters for connection string, table name, smtp server, user and password, and so on in app.config. In the main loop, place a timer - maybe to trigger each 5/10 seconds.

In the OnTimer, do a query to retrieve all the not-sent emails. Then for each of them, try to send them. If OK, update the row for status to be set as sent. If error, also update the row. When no more rows are to be processed, sleep for the next timer call.

And that's it! Let the SMTP Server deal about the delivery queue.

If you need it, there is an interesting Opensource SMTP component that you can use if your mail server uses a non-standard port or if you need to authenticate first. It is at http://sourceforge.net/projects/opensmtp-net/
0
JunkManAuthor Commented:
Hi,

Thanks, that's exactly what i wanted, just a couple of questions, i will be developing the Windows Service in my local machine i do i go deploying it to my production server? Do i need to setup any scheduling for it to run at? Or i can incorporate it whitin the service? I have never developed on of these any further help would be apreciated, i would increase the points of course...

Thanks,
0
fernandonajeraCommented:
If you develope your Windows Service in .NET, you just need to xcopy the bin folder to the production server and then run a simple command:

installutil path\to\file.exe

InstallUtil is a program included with .NET Framework (usually at %windir%\Microsoft.NET\Framework\version\installutil.exe) and is responsible to install and uninstall windows services programmed in .NET. (FYI: installutil /u to uninstall).

Of course, you can do an installer for this. Maybe the installer project included in VS.NET can be used - I don't know, because I've always used Inno Setup which I found more... understandable.

Windows Services has 2 main events: one launched when the service starts (OnStart) and one launched when the service stops (OnStop). In OnStart, you should create a Timer object, attach your event handler to it, and start it. In that eventhandler (Timer.OnTimer) you'd process your enqueued messages as described in the other post. You'd only stop the timer in the OnStop event - when the service is going to shutdown.

If you need more information let me know.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JunkManAuthor Commented:
Sorry fernando, i'm on hollidays and i totally forgot to accept your answer, it works as a treat, although OpenSMTP is a bit buggy, i've decided to go with ASPEmail as i had already bought the ASP version and they now have a .NET Lib.. Thanks anyway. I've increased 100 points to the question..

Thanks once again!...
0
fernandonajeraCommented:
I told you about OpenSMTP because it is free, but of course any other email component will work. Anyway, I'm glad my solution was useful. Good luck!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.