I am using SQL Server 2008 R2. When I execute sp_send_dbmail
I can't change the FROM_ADDRESS
from the default one that our DBA specified. Why is there this parameter if it doesn't work? How do I specify a "custom" FROM_ADDRESS
?
Sends an e-mail message to the specified recipients. The message may include a query result set, file attachments, or both. When mail is successfully placed in the Database Mail queue, sp_send_dbmail returns the mailitem_id of the message. This stored procedure is in the msdb database.
The Database Mail external program logs activity and displays the log through the Windows Application Event Log and the sysmail_event_log view in the msdb database. To check the status of an e-mail message, run a query against this view.
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. The value column shows '0', so Database Mail is off.
sp_send_dbmail (Transact-SQL) Sends an e-mail message to the specified recipients. The message may include a query result set, file attachments, or both. When mail is successfully placed in the Database Mail queue, sp_send_dbmail returns the mailitem_id of the message. This stored procedure is in the msdb database.
Msg 15281, Level 16, State 1, Procedure sp_send_dbmail, Line 0 SQL Server blocked access to procedure 'dbo.sp_send_dbmail' of component 'Database Mail XPs' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Database Mail XPs' by using sp_configure.
Let's fire up SQL Server and give it a try: Msg 15281, Level 16, State 1, Procedure sp_send_dbmail, Line 0 SQL Server blocked access to procedure 'dbo.sp_send_dbmail' of component 'Database Mail XPs' because this component is turned off as part of the security configuration for this server.
To start Database Mail, use sysmail_start_sp. When **@profile** is not specified, sp_send_dbmail uses a default profile. If the user sending the e-mail message has a default private profile, Database Mail uses that profile. If the user has no default private profile, sp_send_dbmail uses the default public profile.
Did you try in this exact format:
@from_address = 'custom display name <custom_address@your_domain.com>'
? Also, according to the documentation, you need to be sure that your SMTP server will accept an override - it may be getting rejected at the server and has nothing to do with your code.
Finally, it is possible that under 2005 compatibility mode, the @profile_name
will not be visible. (I can't confirm this right now, but this was a new parameter added in SQL Server 2008.)
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