How to solve a mail issue Failed to initialize sqlcmd library with error number -2147467259?
From your example, you are trying to insert the results of your query into a table variable and then trying to use that table variable in the sp_send_mail procedure call. That won't work. sp_send_mail needs to reference a real table and not a temp table either.