Change or customize “from” portion/header of the email when calling sp_send_dbmail in SQL server

Disclaimer:Hey Guys, this post contains affiliate link to help our reader to buy best product\service for them. It helps us because we receive compensation for our time and expenses.

Scenario:-

Recently, I had received a request from one of the customer to send some report from SQL to his management and it looks pretty simple to fulfill this request via send_db_mail.

 

But while using existing DB profile (profile which was being used by DBA monitoring) the email sent to customer or management consist server name in header section of the email (derived from existing DB profile), this could be avoided by creating new DB profile with required display name while account creation but we did not want to create a new DB profile rather using existing one and hiding server name from the header section.


Is it possible, Yes!

This is possible using below parameter while calling sp_send_dbmail

@from_address = 'custom display name <custom_address@your_domain.com>'

Example:-

sp_send_dbmail [ [ @profile_name = ] 'profile_name' ]     [ , [ @recipients = ] 'recipients [ ; ...n ]' ]     [ , [ @copy_recipients = ] 'copy_recipient [ ; ...n ]' ]     [ , [ @blind_copy_recipients = ] 'blind_copy_recipient [ ; ...n ]' ]     [ , [ @from_address = ] 'custom display name <custom_address@your_domain.com>'     

Try this out!


Treat your kid like a darling for the first five years. For the next five years, scold them. By the time they turn sixteen, treat them like a friend. Your grown up children are your best friends!!

–Chanakya

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s