我有一个 SQL 作业在没有向配置的收件人发送电子邮件的情况下完成。这是我正在使用的存储过程。名字相应地改变了。所有其他邮件都通过存储过程通过数据库邮件发送。我相信邮件发送有大小限制。
USE [master]
GO
/****** Object: StoredProcedure [dbo].[spReport] Script Date: 3/3/2016 3:29:27 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: J Romero
-- Create date: 10/21/2015
-- Description: Procedure to email a list of Subscribers for the last 12 months
-- =============================================
ALTER PROCEDURE [dbo].[spReport]
AS
BEGIN
SET NOCOUNT ON;
dECLARE @p_recipients as nvarchar(max), @p_profile_name as nvarchar(max)
declare @TableHTML nvarchar(max)
SET @p_recipients = N'[email protected];[email protected];[email protected]'
set @TableHTML =
N'<H1>eMail Subscribers-Last 12 Months</H1>' +
N'<table border="1">' +
N'<tr><th>eMail Address</th><th>Date Subscribed</th></tr>' +
Cast ((select td = email, '',
td = Date_Subscribed
FROM email_subscriptions
where date_subscribed > dateadd(D,-365,getdate())
ORDER BY date_subscribed
for xml path('tr'), type) as nvarchar(max)) + N'</table>' ;
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Admin',
@recipients = @p_recipients,
@reply_to = '[email protected]',
@blind_copy_recipients = '[email protected]',
@subject = 'Subscribers-Last 12 Months',
@body = @TableHTML,
@body_format = 'HTML'
END
每个其他程序都在发送邮件,并且日志中没有出现错误。好的,邮件配置文件已启用。我发现您可以从数据库发送的电子邮件有大小限制。有没有设置可以改变这个?
问题是大小限制。我们只是使用更短的日期范围使文件更小。还通过 sql 函数更改了大小限制,以防我们以后想选择更大的日期范围。
参考:数据库邮件存储过程 (Transact-SQL)
特别: