trigger system to send an email 30 days prior to a due date.

Kenn_rosie

New member
Joined
Nov 30, 2005
Messages
4
Programming Experience
5-10
I am using visual studio.net.
I want the system to send an email 30 days prior to a due date.
Example:
Employee Performance due date: 12 Dec 2005
I would like the system to generate an email to the supervisor on 12 Nov. 2005
I have not found any material on how to perform this function.
 
You would need to check the current date against your due date to see how many days difference there are:
VB.NET:
Dim days As Integer = dueDate.Subtract(Date.Today).Days
Once you have the number of days you can decide whether you need to send an e-mail or not. You would presumably compare the number of days to 30 and perhaps 0. Bear in mind though that if you only test whether it is equal to thirty then if you app is not run on that particular day for some reason then the message will not be sent. If you test whether it's less than or equal to 30 then it will be sent every day unless you remember that it has already been sent. As for sending the e-mail, you need to use the System.Web.Mail namespace in .NET 1.x and System.Net.Mail in .NET 2.0. There is plenty of information on MSDN and all over the Net on sending e-mail, plus there are some free e-mail components that simplfy the process, but it's not too hard to begin with. The main reason to use a component is for POP3, not SMTP.
 
Additionally, if you want to check intermittently rather than just when your app starts you can use a Timer and set its Interval to something like 24*60*60*1000 (1 day in milliseconds).
 
Back
Top