Generate report emailed to users periodically?

I am planning to deploy a web application on Xojo Cloud. Once a week I want to send an Excel file to users of the application. Just wondering what is the best way to schedule this to happen on a particular day of the week?

You need to be a bit more specific:

  • Do you need help with the interface?
  • Do you need help with the report?
  • Or do you need help with the sending of emails?

Interface:

I have “Day of Month Picker” at Xojo + Alfred to select a day in a week or a month.

Obviously, you can’t use that in a web app. But you should be able to do something similar with a canvas.

Sending emails: Find yourself some transactional email sender like Mailgun or similar (NOT Sendgrid, they suck).

These days I have some json (even with an attachment) sent to a php script which then sends the email. It’s a bit of work. But these days even without me having much php experience ChatGPT can write such a script just fine. Not sure if this is relevant for a web app.

Sorry, I thought I was specific enough. I do not need help with sending the email or generating the Excel file.

Just wondering how to schedule the sending of the email with the Excel file attached. Since this needs to be done once a week, how do I trigger the creation of the Excel file and sending of the email.

Can I just use a timer in the App class of the web app or do I need to use a console app with the timer that will trigger everything?

On a server in which you manage things yourself, the best practice is to set up a cron job to run at a regularly scheduled interval. Since Xojo Cloud manages many things for customers, they lose access to things like cron jobs.

It’s very likely possible with an in-app Timer, but I’ve never really trusted long-period timers. If I was confined to an in-app Timer, I’d set a shorter period and check “is it time yet?”

Tim, thank you for the reply.

Please excuse me if my questions are overly naive but this is my first web application.

I have tested the following in a web app that I’ve run in debug mode.

I have a timer in the App Class that runs every hour and checks to see if the day of the week corresponds to the day of the week the Excel file should be sent out. If it is, then it generates the Excel file and emails it to the correct users.

The question I do not know is if I put this in the App Class of the app, is the app always running even if no users have accessed it or do I need to put the timer in a console app that is always running on the server to accomplish this?

I have a couple of web apps that send an email nightly. I store the next time the email needs to be sent in the DB, and then have a timer that fires occasionally and checks if the current time is after the time in the DB. My timer fires every couple of seconds, but that’s because it also checks for user generated mail that needs to be sent. Never had any issues with it…

You could set the timer period to 30 minutes or something like that if you don’t mind the actual send time to be off from the scheduled time. Or you could get fancy and have the timer shorten its own period the closer it gets to the scheduled time.

Xojo Web apps are servers that are always running whether or not a user is connected. You don’t need an additional console app for the job you want to do.

Tim, that’s the answer I was looking for. Thank you!

Clifford, are you running on Xojo Cloud or some other server? Just curious because I’ll be using Xojo Cloud.

My app will be sending an email out once a week so I just have the timer run every hour to see if it is Sunday and if it is, then it will send the email out. Nothing intensive for the timer to do.

I have one on Xojo Cloud, and the rest run on AWS machines.

Curious… Any advantages of one over the other?

For all the things you lose by not having the server managed by Xojo, you gain as an advantage of “I can configure that.” Xojo staff offer great support by email, for some that’s well worth the cost. For others, needing to wait for customer support to fix a problem can be a drawback.

An example of something you gain would be the cron jobs that would have helped schedule an email report. You can also do things like host a normal website or PHP scripts right next to the web app. For many, the cost savings is a huge advantage.

With the free trial for Lightsail and the demo mode of my app Lifeboat, you can try out deploying a Web App to your own Linux server totally free in just minutes.