We have similar things going on here. We'd write a query because it was
faster than writing a program. Then we had to do something special to
format it. Then we had to do another special thing to send it. Then
another special thing to avoid sending it if it was empty.
It turned into a lot of work in order to save ourselves the work of
writing a program. I guess in the end it was OK because the work was
spread out over time...
Today, I'd argue for a proper program that does the extract, formatting,
and if there's something to be sent, do the emailing.