Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stored procedure using SP_SEND_DBMAIL sending duplicate emails to all recipients

I have a stored procedure that is run every night which is supposed to send the results of a query to several recipients. However on most days it ends up sending a duplicate email a minute later. The code I am using is as follows (all emails and database refs have been changed):

EXEC msdb.dbo.sp_send_dbmail
@recipients = '[email protected]',
@copy_recipients = '[email protected];[email protected];[email protected]',
@subject = 'Example Email',
@profile_name = 'ExampleProfile',
@query = 'SELECT name
    FROM table
    WHERE date BETWEEN (getdate() - 1) AND getdate()',
@attach_query_result_as_file = 1

Any help with this would be greatly appreciated.

like image 341
andewM Avatar asked Mar 20 '13 11:03

andewM


1 Answers

The solution has turned out to be reducing the number of Account Retry Account on the server to 0 (within the Database Mail Configuration Wizard).

like image 160
andewM Avatar answered Nov 10 '22 00:11

andewM