Fire automated e-mail at a certain time with java

Asked

Viewed 227 times

3

My system has the part of dental consultations and I need to send email to the client, if your consultation is on that day.

For example: Run an automatic e-mail trigger at midnight every day. This email trigger will check if you have queries that day and if you have, will send the email.

How do I run this check with java?

  • Your question is to check or to schedule the execution of a code? In the first case, you need to know your data model. In the second, varies operating system, you need to inform.

  • I want to schedule the execution of query check. Midnight run a method that checks for queries that day.

  • So which operating system??

  • It is Windows :D

  • There are two ways of scheduling, "Jobs", in java applications, there is a post in this link that will surely guide you.

  • Another option would be to use the EJB to make the scheduling in the java itself, in the same method you could do the checking you wanted. http://blog.caelum.com.br/agendando-tarefas-com-o-timerservice-do-ejb-3-1/

Show 1 more comment

1 answer

0


There are task scheduling frameworks, however to just run a daily script you can use much simpler solutions. The operating systems have a task scheduler: in linux has the cron, in windows has the Agendador de Tarefas (less creative name, by the way).

Basically you create a program in java that when running sends the emails with the queries, without worrying about the time. To schedule, you create a script like this:

@echo off
REM run the program
"C:\Program Files\Java\jdk1.7.0\bin\java.exe" -jar "C:\Users\User1    \Documents\project\emailConsulta.jar"

Then, just create a task in the Windows Task Scheduler, accessed with Win+R > type "Taskschd.Msc" > Enter. There you control on which days of the week it will run, at what time, among other options.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.