Solved

Email solution independent from web site

Posted on 2006-06-23
5
220 Views
Last Modified: 2010-04-17
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,
0
Comment
Question by:JunkMan
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:fernandonajera
ID: 16976379
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
 
LVL 3

Author Comment

by:JunkMan
ID: 16978472
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
 
LVL 4

Accepted Solution

by:
fernandonajera earned 225 total points
ID: 16978620
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
 
LVL 3

Author Comment

by:JunkMan
ID: 17036116
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
 
LVL 4

Expert Comment

by:fernandonajera
ID: 17036284
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now