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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With