我编写了一个触发器,用于在特定列更改后抓取某一行记录,并将记录存储到另一个名为Feedback的表中。
然后我尝试使用以下代码通过sp_send_dbmail将更改通过电子邮件发送给我们的用户。
然而,在测试代码时,我一直得到以下错误消息:
Msg 14607, Level 16, State 1, Procedure sysmail_verify_profile_sp, Line 42
配置文件名称无效
配置文件名为Feedback Survey
,并使用数据库邮件配置向导正确设置。
我做错了什么?
Declare @email nvarchar(MAX),@content1 nvarchar(4000), @RequestID INT, @custname nvarchar(200)
select @email = '', @content1 = '', @RequestID = 0, @custname = ''
SET @content1 = 'SET QUOTED_IDENTIFIER OFF;
This is a computer generated email message.
Please DO NOT use the REPLY button above to respond to this email.
Dear '+ @custname +':
Thank you for using the order processing system.
Please click the link below to complete a survey
http://satisfactionsurvey.php?wo=@RequestID
Regards,
Order administrator. '
SELECT top 1 @email = @email+';'+Email, @content1 = @content1
FROM Feedback
WHERE Status = 'Completed'
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Feedback Survey', -- our defined email profile or static info
@recipients = @email, -- Authorized user email
@blind_copy_recipients = 'jab.judah@yahoo.com',
@subject = 'Feedback Survey',
@body = @content1;
--delete records after sending email.
Delete FROM Feedback
在数据库邮件配置向导中,转到管理配置文件安全性并检查公共和私有配置文件的设置。
检查您使用的登录是否连接到配置文件"反馈调查"。
更详细的信息可以在Msg 14607, Level 16, State 1- profile name not valid (Internet Archive link from 2014-01-15)