SSIS is probably the way to go, but if you want T-SQL to do it, try this..
I'm not going to write the complete program for you, but here are the major points...
determine the split character:
SET @CSV=',' --use CHAR(9) for tab
build your CSV string one line at a time, looping over the results (do this for each line):
SET @FileMessage=ISNULL(CONVERT(varchar(10),column1),'')+@CSV+ISNULL(CONVERT(varchar(10),column2),'')
SET @ExecuteString = RTRIM('echo ' + @FileMessage + ' >>' + @FileName)
--append it to you file, you'll need write permissions
EXEC @ReturnValue=master..xp_cmdshell @ExecuteString, no_output
actually send the mail, after the file is completely built:
EXEC xp_sendmail { [ @recipients= ] 'recipients [ ;...n ]' }
[ ,[ @message= ] 'message' ]
[ ,[ @query= ] 'query' ]
[ ,[ @attachments= ] 'attachments [ ;...n ]' ]
[ ,[ @copy_recipients= ] 'copy_recipients [ ;...n ]'
[ ,[ @blind_copy_recipients= ] 'blind_copy_recipients [ ;...n ]'
[ ,[ @subject= ] 'subject' ]
[ ,[ @type= ] 'type' ]
[ ,[ @attach_results= ] 'attach_value' ]
[ ,[ @no_output= ] 'output_value' ]
[ ,[ @no_header= ] 'header_value' ]
[ ,[ @width= ] width ]
[ ,[ @separator= ] 'separator' ]
[ ,[ @echo_error= ] 'echo_value' ]
[ ,[ @set_user= ] 'user' ]
[ ,[ @dbuse= ] 'database' ]