Using JavaMail to send email to users automatically on exceeding the due date
I have a ISSUEBOOK
database(mysql) which contains following field/columns
- loginID
- IssueDate
- DueDate
Now i need to implement开发者_运维百科 a JAVA
code which should automatically
send mail to the users who exceeds their due date.
Information about users email address can be retrieved from STUDENTACCOUNT
database using their loginid.
So help me in providing the pseudocode/Algo to achieve this. I am using Struts 1.3.8 framework.
And if i want to run the above implemented code regularly at a fixed time than if am correct i have to implement quartz scheduler
.
Your question covers far too many topryics (design, algo and program) to get clear answer. Please visit https://stackoverflow.com/faq )
You do not have to use 'quartz' scheduler, but it is one of the easy and useful one (we use that). cron/at could be enough in your case.
Once you implement the scheduler, schedule the job to every day fixed time(no point in running it every hour unless the users are in multiple time zones. The job should check if there are any records (from ISSUEBOOK ) with with due date in old than current time.
following query could give rough idea on getting
select user.email from STUDENTACCOUNT user, ISSUEBOOK rentals
where user.<id> = rentals.loginid --assuming a foreign key
and rentals.duedate < now -- mysql built in function
Get the unique records , and then send mails.
Please do work on the project and ask specific questions.
精彩评论