SQL 为什么在使用数据库邮件时出现以下错误 -> Procedure sysmail_verify_profile_sp, profile name is not valid?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31922351/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 03:54:40  来源:igfitidea点击:

Why am I getting the following error when using database mail -> Procedure sysmail_verify_profile_sp, profile name is not valid?

sqlsql-server

提问by Chidi Okeh

I wrote a trigger to grab a certain row of records after a specific column change and store the records into another table called Feedback.

我编写了一个触发器来在特定列更改后抓取某行记录,并将这些记录存储到另一个名为“反馈”的表中。

Then I am trying to using the following code to email the changes to our users using sp_send_dbmail.

然后我尝试使用以下代码通过 sp_send_dbmail 将更改通过电子邮件发送给我们的用户。

However, when testing the code, I keep getting the following error messages:

但是,在测试代码时,我不断收到以下错误消息:

Msg 14607, Level 16, State 1, Procedure sysmail_verify_profile_sp, Line 42
profile name is not valid

The profile is called Feedback Surveyand it is set up correctly using Database Mail Configuration wizard.

配置文件被调用Feedback Survey并使用数据库邮件配置向导正确设置。

What could I be doing wrong?

我可能做错了什么?

My code is below and thanks in advance for your help.

我的代码在下面,在此先感谢您的帮助。

 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 = '[email protected]',
@subject = 'Feedback Survey',
@body = @content1;

--delete records after sending email.
Delete FROM Feedback

回答by CMS

From Database Mail Configuration --> Mail Profile Security check settings for public and private profiles. Check if the Login that you use is connected to the profile 'Feedback Survey'.

从数据库邮件配置 --> 邮件配置文件安全检查公共和私人配置文件的设置。检查您使用的登录名是否已连接到配置文件“反馈调查”。

More detailed information can be found in this blog post: https://cms4j.wordpress.com/2013/12/17/msg-14607-level-16-state-1-profile-name-is-not-valid/

更详细的信息可以在这篇博文中找到:https: //cms4j.wordpress.com/2013/12/17/msg-14607-level-16-state-1-profile-name-is-not-valid/