Hi,

Can anyone tell me if a local temporary table can be referenced in the @query
parameter of the extended procedure xp_sendmail and if so, how?

When I execute the following statements in Query Analyzer, I get the error
message provided below.

CREATE TABLE #TestEmailFile (TestEmailRow varchar(500) null)
INSERT INTO #TestEmailFile VALUES( 'Hello')
EXEC master.dbo.xp_sendmail @recipients = 'EmailAddress',
@query = 'SELECT * FROM #TestEmailFile',
@subject = 'You have mail',
@message = 'See attachment',
@attach_results = 'TRUE',
@width = 500

ODBC error 208 (42S02) Invalid object name '#TestEmailFile'.

Please help!