Stored procedure using SP_SEND_DBMAIL sending duplicate emails to all recipients
34,721
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).
Author by
andewM
Updated on July 23, 2022Comments
-
andewM almost 2 years
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.
-
andewM about 11 yearsThanks for the answer, but I have checked the job list and I'm sure the procedure is only being run once.
-
andewM about 11 yearsThank you for your input. I disabled the job to see if the procedure was being run elsewhere, however I found that this was not the case and ended up recreating the job to see if it fixed the problem. It seems to have done the trick.
-
andewM about 11 yearsThanks for the input, but I've checked and I'm not using any Outlook Mail filters.
-
Igor Voplov about 11 yearsI'm glad to know I helped :)