Search
Close this search box.

I get this message: profile name is not valid [SQLSTATE 42000] (Error 14607) using sp_send_dbmail. Why?

The most likely reason is that your profile has not been configured, or you are using an incorrect name under the @profile_name parameter.  To determine your profile settings, use this query:

SELECT [profile_id]
      ,[name]  
      ,[description]
      ,[last_mod_datetime]
      ,[last_mod_user]
FROM [msdb].[dbo].[sysmail_profile] 

If after you have checked the results of this query and you are using the correct profile name, check how you are passing the parameter values.

Don’t do this:

exec msdb.dbo.sp_send_dbmail @subject, @body, @profile_name, @recipients 

…  it will still fail because you need to explicitly define the parameter values …

For example,

@subject = ‘Some topic or another’

So you would either have to do this:

exec msdb.dbo.sp_send_dbmail @subject = ‘Some topic or another’, @body = ‘read this!‘ …etc.,

or

declare @subj varchar(100)

set @subj ‘Some topic or another’

exec msdb.dbo.sp_send_dbmail @subject=@subj … etc.,…

This article is part of the GWB Archives. Original Author: Ask Paula!

Related Posts