I have a windows account with users group and trying to exec sp_send_dbmail but getting an error:
profile name is not valid.
However, when I logged in as administrator and execute the sp_send_dbmail, it managed to send the email so obviously the profile name does exist on the server.
[ @profile_name = ] 'profile_name' Is the name of the profile to send the message from. The profile_name is of type sysname, with a default of NULL. The profile_name must be the name of an existing Database Mail profile.
On the Manage Profiles and Accounts page, select Create a new profile option, and click Next. On the New Profile page, specify the Profile name, Description and add accounts to be included in the profile, and click Next.
When a profile name or profile id is specified, sysmail_help_profile_sp returns information about that profile. Otherwise, sysmail_help_profile_sp returns information about every profile in the SQL Server instance. The stored procedure sysmail_help_profile_sp is in the msdb database and is owned by the dbo schema.
Is it Enabled? First to check to make sure that Database Mail is enabled. Look in 'sys. configurations' for the setting Database Mail XPs, and if it is set to 0, Database Mail is not enabled.
You need to grant the user or group rights to use the profile. They need to be added to the msdb database and then you will see them available in the mail wizard when you are maintaining security for mail.
Read up the security here: http://msdn.microsoft.com/en-us/library/ms175887.aspx
See a listing of mail procedures here: http://msdn.microsoft.com/en-us/library/ms177580.aspx
Example script for 'TestUser' to use the profile named 'General Admin Mail'.
USE [msdb] GO CREATE USER [TestUser] FOR LOGIN [testuser] GO USE [msdb] GO EXEC sp_addrolemember N'DatabaseMailUserRole', N'TestUser' GO EXECUTE msdb.dbo.sysmail_add_principalprofile_sp @profile_name = 'General Admin Mail', @principal_name = 'TestUser', @is_default = 1 ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With