You need
- A scheduler that is triggering the sending
- Code that queries the settings (if not passed by the scheduler)
- Code that generates the reports in the required formats
- Code that sends mails with attachments
The last three points are not difficult to implement but the first one requires having a concept which depends on your general setup which we don't know. The simplest solution would by a periodically called event (e.g. every minute) that checks all accounts for their trigger time. But that would not scale well for many users.
Quote:
all the process should be done in a method
Putting all the above into one method would result in a quite large and nearly unmaintainable method. I hope you wanted to write
module instead (e.g. containing the scheduler and a class for generating and sending mail that contains methods for the above listed tasks).