How can I use temp tables with xp_sendmail e.g. I have a temptable called #email and then I want to execute: xp_sendmail @query = 'select * from #email', but I get the error: Invalid object #email.
The problem might be the scope of the temp table. xp_sendmail runs from the master database whereas you are executing the proc from your user database and the temp table might not be 'visible' in the master db.
Try making the temp table a global temp table by calling it ##email.