存储过程使用SP_SEND_DBMAIL向所有收件人发送重复的电子邮件 [英] Stored procedure using SP_SEND_DBMAIL sending duplicate emails to all recipients

查看:293
本文介绍了存储过程使用SP_SEND_DBMAIL向所有收件人发送重复的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个每天晚上运行的存储过程,应该将查询的结果发送给多个收件人。然而,在大多数情况下,最后一分钟后就会发送重复的电子邮件。我使用的代码如下(所有的电子邮件和数据库参考被更改):

  EXEC msdb.dbo.sp_send_dbmail 
@recipients ='email1@email.com',
@copy_recipients ='email2@email.com; email3@email.com; email4@email.com',
@subject ='示例电子邮件',
@profile_name ='ExampleProfile',
@query ='SELECT name
FROM table
WHERE date BETWEEN(getdate() - 1)AND getdate()',
@attach_query_result_as_file = 1

对此的任何帮助将不胜感激。

解决方案

解决方案原来是将服务器上的帐户重试帐号减少到0(在数据库邮件配置向导中) / p>

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 = 'email1@email.com',
@copy_recipients = 'email2@email.com;email3@email.com;email4@email.com',
@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).

这篇关于存储过程使用SP_SEND_DBMAIL向所有收件人发送重复的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆