How to send email from application without user interaction?

Hi!

I am trying to achieve that my Vaadin 8 application automatically sends email every 1st of the month. (eg. monthly report).
I already implemented sending email via Button, but i want to send email without user interaction. So even if nobody visits the application it still sends emails. How do i achieve that?

Any recommendations or hints will be much appreciated.

Best regards,
Gregor

Hi Gregor

This sounds like a job for [Cron]
(https://en.wikipedia.org/wiki/Cron). It lets you schedule jobs at times like every 1st of the month (–> 0 0 1 * * ), when it will run a script (which in your case would send emails).

There also is a [Quartz Scheduler]
(https://stackoverflow.com/a/22164401/3441504) that runs scheduled jobs within an application, basing on Cron too. I have no experience with this one though but it looks promising.

Hi Kaspar,
thanks for the advice! I tried Quartz Scheduler but now i am facing a different problem…
Well i am new to Vaadin and Spring type of development and i am not sure how to inject @Autowire Entity Repository into a Job that Quartz schedules. So my next question is: How do i autowire a repository from database that i want to work inside a Job class?

Thanks

Gregor