Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

sp_send_dbmail problem

$
0
0

I am trying to send an email with the results in the body of the message.  Below is the code and below that is the error.

 

DECLARE @mailprofile VARCHAR(200)
 declare @query nvarchar(max) 
 SET @query = 'select top 1 AccountID from operations.dbo.Accounts'--'select SQL from operations..ChangeAttempt'
SET @mailprofile = (SELECT top 1 name FROM   msdb.dbo.sysmail_profile)

EXEC msdb.dbo.sp_send_dbmail
  @profile_name = @mailprofile,
  @recipients = 'anaylor@lamar.com',
  @query = @query,
  @subject = 'Current Test EMAIL' ;

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 517
Query execution failed: Msg 15404, Level 16, State 19, Server SQLDEVELOPMENT2, Line 1
Could not obtain information about Windows NT group/user 'LAMARHQ\anaylor', error code 0x6e.


Alan


Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>