Run script and send email with csv file of the script result ?

Snehal13
Kilo Sage

I have server side script that runs and queries incident table and returns matching incidents. This output result from this script needs to emailed in a csv file, so how to reuse this code to email file