I was asked to done a task , i did it but i don't know if it can be done with better way or not.
I have a database table called eventtbl , it has event name , event datetime
I was asked to send mail to all people who going to event before event start datetime with 1 HR
(there are another table for users and another one for users who are going to events)
For example :-
Event name : 2016 Party
Event Date : 2016-01-26 06:00 PM
so if user X and Y subscribed in that , they should get a mail at 2016-01-26 05:00 PM
i did it by creating 2 files , sendmails.sql , sendmails.bat
sendmails.sql => it has a query of sending mails
sendmails.bat => it executes sendmails.sql
and create a job from windows task scheduler to run sendmails.bat every 1 min
every 1 min , query runs ,
i add 1 HR to the current datetime(after remove seconds) and see if the result datetime will match event datetime or not
if yes = >send mails to subscribed users .
if no =>do nothing(there is no event after 1 Hr)
It works fine without any problems , but i need to know if there are better solutions or not.
Thanks