I've a procedure which generates a tab delimited text file and also sends an email with a list of students as attachment using msdb.dbo.sp_send_dbmail.
When I execute the procedure thoruhg SQL server management studio, it sends only one email. But I created a SSIS package and scheduled the job to run nightly. This job sends 4 copies of the email to each recipient.
EXEC msdb.dbo.sp_send_dbmail @profile_name = 'A'
,@recipients = @email_address
,@subject = 'Error Records'
,@query = 'SELECT * FROM ##xxxx'
,@attach_query_result_as_file = 1
,@query_attachment_filename = 'results.txt'
,@query_result_header = 1
,@query_result_width=8000
,@body = 'These students were not imported'
I've set following parameters to 0 (within database mail configuration wizard), to see if it makes any difference. But it didn't resolve the problem. AccountRetryAttempts 0 AccountRetryDelay 0 DatabaseMailExeMinimumLifeTime 0
Any suggestions?