During working for script to send mail alerts, i just learned as we can change display name for the mail at runtime. It will normally use profile name or display name which configured in database mail profile for mail. Below query will use display name "MailProfile1".
EXEC MSDB.DBO.SP_SEND_DBMAIL @from_address = 'abc@mail.com' , @recipients = 'xyz@mail.com' , @subject = 'This is test mail' , @body = 'This is test mail' , @profile_name = 'MailProfile1' , @body_format = 'HTML' GO
But we can change display name other than configured with small change while firing it as below,
EXEC MSDB.DBO.SP_SEND_DBMAIL --@from_address = 'abc@mail.com' @from_address = 'test mail <abc@mail.com>' -- Whatever you can write in place of 'test mail' , @recipients = 'xyz@mail.com' , @subject = 'This is test mail' , @body = 'This is test mail' , @profile_name = 'MailProfile1' , @body_format = 'HTML' GO
Published under: SQL Server Tips · · · ·
The reason this is possible is because database mail uses SMTP relay to send out the E-mails. SMTP would allow you to tweak almost anything.