Is there a way for an email job to automatically pick the latest month's file?

I currently have a use case where I am exporting the most recent month’s data and emailing it. I can have the export job name the file for the previous month each month eg. data_export_04_2021.csv

Is there a way for the email job to pick the most recent month’s file? So in June I would want the email job to email data_export_05_2021.csv and in July I would want to email data_export_06_2021.csv

Thanks,

Will

Hey @will! Thank you for the great question.

Currently Mitto’s email job type only supports attachments that are specifically named.

For example:

{
  "attachments": [
    "/var/mitto/data/data_export_04_2021.csv",
    "/var/mitto/data/data_export_05_2021.csv",
    "/var/mitto/data/data_export_06_2021.csv"
  ],
  ...
}

I will create a couple improvement requests so the email job’s attachments can support RegEx matching or the “path variables” that the CSV output supports.

Then you could potentially configure the email job similar to:

{
  "attachments": [
    "/var/mitto/data/data_export_{month}_{year}.csv"
  ],
  ...
}

Or to send all files matching this pattern:

{
  "attachments": [
    "/var/mitto/data/data_export_*.csv"
  ],
  ...
}