Build CSV from SQL query and send an email.