使用不是sysadmin权限的账号执行存储发邮件,报异常profile name is not valid,

        EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'mail',
@recipients = 'xx',
@attach_query_result_as_file = 0,
@body = 'tttt',
--@file_attachments='',
@subject='xx',
@body_format = 'xx'

解决

1.给开sysadmin权限

2.如果不能给开sysadmin权限,则要将该配置文件改为公用。

EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
@principal_name = 'public',
@profile_name = 'Mail',
@is_default = 1 ;

并给该账号开启msdb的DatabaseMailUserRole权限,

profile name is not valid,The EXECUTE permission was denied on the object 'sp_send_dbmail', database 'msdb', schema 'dbo'.-LMLPHP

否则报错

The EXECUTE permission was denied on the object 'sp_send_dbmail', database 'msdb', schema 'dbo'.

05-11 22:21