我是SSIS的新手。我在我的一个存储过程中执行sp_send_dbmail时遇到问题,该过程由SSIS中的Execute SQL任务运行。主要问题是,即使我运行此SP的配置文件不存在,它也不会引发任何错误并成功完成。我怀疑存在配置问题,但无法诊断。
我发现我的登台服务器上未配置SMTP。可能是唯一原因吗?即使是这样,它至少也应该引发错误,但是在日志中我看不到相同的任何错误消息。
此外,如果我直接通过SQL运行此SP,则会收到“配置文件不存在”错误。但是,当我通过SSIS(执行sql任务)运行相同的SP时,它就可以成功执行。
任何有关此问题的指导都可以提供很大帮助。
这就是我给sp_send_dbmail打电话的方式。
EXEC msdb.dbo.sp_send_dbmail
@profile_name ='触发触发',
@recipients ='myemailID@test.com',
@subject ='这是从SP发送邮件的SP'
答案 0 :(得分:3)
sp_send_dbmail
仅使邮件排队。不尝试发送,不验证电子邮件配置文件,不能引发您抱怨的任何错误。
在此处阅读如何检查已排队的电子邮件的状态:Check the Status of E-Mail Messages Sent With Database Mail:
USE msdb ;
GO
-- Show the subject, the time that the mail item row was last
-- modified, and the log information.
-- Join sysmail_faileditems to sysmail_event_log
-- on the mailitem_id column.
-- In the WHERE clause list items where danw was in the recipients,
-- copy_recipients, or blind_copy_recipients.
-- These are the items that would have been sent
-- to danw.
SELECT items.subject,
items.last_mod_date
,l.description FROM dbo.sysmail_faileditems as items
INNER JOIN dbo.sysmail_event_log AS l
ON items.mailitem_id = l.mailitem_id
WHERE items.recipients LIKE '%danw%'
OR items.copy_recipients LIKE '%danw%'
OR items.blind_copy_recipients LIKE '%danw%'
GO
有关该主题的更多文章:
答案 1 :(得分:0)
您的错误非常清楚,它要求什么。首先,创建一个配置文件并记下您将在向导中输入的所有值。 This指南将帮助您正确创建个人资料。
一旦您验证了dbmail配置文件的设置,就可以对其进行测试了。如果您无法通过存储的proc发送电子邮件,我想与AD管理员或负责设置电子邮件服务器的人员联系。这是为了确保您可以匿名发送电子邮件,并解决任何潜在的中继服务器问题。希望这会有所帮助。