Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 sp_send_dbmail

Author  Topic 

igorblackbelt
Constraint Violating Yak Guru

407 Posts

Posted - 2007-09-18 : 17:07:12
Not sure what's wrong, this could be either an issue on my code or on the permissions, I have access to table I want to send the results from (table1) and the procedure gets executed successfully if I remove the @query parameters.


EXEC msdb.dbo.sp_send_dbmail
@profile_name ='DT',
@recipients ='foo@foo.com',
@query = 'select * from staging..table1',
@subject = 'IDs Moved to Production',
@attach_query_result_as_file = 1;


Error msg


Msg 22050, Level 16, State 1, Line 0
Error formatting query, probably invalid parameters
Msg 14661, Level 16, State 1, Procedure sp_send_dbmail, Line 478
Query execution failed: #65279;Msg 15404, Level 16, State 19, Server TAKKARA, Line 1
Could not obtain information about Windows NT group/user 'DOMAIN\SQLUser', error code 0x5.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-18 : 17:13:24
Under which account is the query run?
Can the Exchange server authenticate you?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

igorblackbelt
Constraint Violating Yak Guru

407 Posts

Posted - 2007-09-18 : 19:26:08
My personal account (Domain Account/Domain Authentication). Yes, I can send/receive emails using my account.
Go to Top of Page

igorblackbelt
Constraint Violating Yak Guru

407 Posts

Posted - 2007-10-31 : 14:30:58
Back to this issue... Even if I login to the server under the SQLAgent's account, I still have an issue...

This is what I'm trying to run now..

exec msdb.dbo.sp_send_dbmail
@profile_name = 'DT',
@recipients = 'foo@foo.com',
@subject = 'Subject',
@body = 'See below, blah blah',
@query = 'select * from [db].[dbo].[table]',
@execute_query_database = 'db',
@exclude_query_output = 1,
@append_query_error = 1;

Error Message:
Msg 15404, Level 16, State 19, Server Server123, Line 1 Could not obtain information about Windows NT group/user 'Domain/SQLAgentAccount', error code 0x5.

I've added myself to the DatabaseMailUserRole, I'm a sysadmin on the machine and I can execute the select statement... Any help really appreciated.
Go to Top of Page
   

- Advertisement -