Please see the below sample code which will send email which will have an csv attachement.
Exec [msdb].[dbo].[sp_send_dbmail]
@profile_name = '
@recipients = 'emailid',
@body = ' Hello Sir,Please find the attached details...',
@body_format ='HTML',
@attach_query_result_as_file = 1,
@query_result_header = 1,
@query_result_no_padding = 1,
@query = 'SET NOCOUNT ON; SELECT EmployeeName, Address FROM EmployeeDetails',
@query_result_separator = ' ',
@exclude_query_output = 1,
@query_attachment_filename = 'EmployeeDetails.csv'