Solved

Email solution independent from web site

Posted on 2006-06-23
5
219 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MaxSpan challenge 9 65
topping1 challenge 7 48
tidtcpserver connection lost handle 2 41
Turning python script into an applet 12 32
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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…

771 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

12 Experts available now in Live!

Get 1:1 Help Now