I created a stored procedure that takes the data from any table and inserts it to CSV or Excel and send it to email or upload it to SharePoint, it works on SQL Server 2019, you can download it from here ExportToExcel.
here's an example on how to use it:
SELECT columna, columnb, "column c"
INTO ##anytemptable --must be a global temp table
FROM yourdb.dbo.yourtable
WHERE somecolumn = 'somecondition'
exec dbo.ExportToExcel
@tablename= '##anytemptable' --must be a global temp table
,@filepath = 'c:\somefolder'
,@filename = 'MyDataInExcel.xlsx'
,@AttachToMail = 1,
,@MailList = 'yourboss@domain.com'
The beauty of this one specifically is that the file is already formatted and easy to read:

There's an easy method of course to export data using CSV, but for some reports, the file becomes very large in size that it couldn't be attached to mail, so using Excel is the wise option here.
You don't need to specify @filepath or @filename, the code will create them automatically and will display the file full path at the end of execution.
You could also use parameter @MailSubject and @MailBody to specify body and subject of the email, the only limitation to that proc is not enabling PSGallery on the target server, if it exists, the code handles installing the module automatically.
If you by any chance do not like fancy formatted and beautiful Excel files, you could just do this:
exec msdb.dbo.sp_send_dbmail
@recipients = 'email@domain.com',
@subject = N'CSV Report',
@body = N'PFA',
@query='SET NOCOUNT ON SELECT * FROM db.dbo.table',
@query_attachment_filename = 'YourReport.csv',
@attach_query_result_as_file = 1,
@query_result_header = 1,
@query_result_width = 32767,
@append_query_error = 0,
@query_result_no_padding = 1,
@query_result_separator = ' '; --specify your column delimiter here