14

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?

Matas Vaitkevicius
  • 58,075
  • 31
  • 238
  • 265
Denis
  • 11,796
  • 16
  • 88
  • 150
  • 2
    What does "can't change" mean? Do you get an error message (and if so, what is it)? Or do you get the e-mail but your `@from_address` hasn't been changed? – Aaron Bertrand Apr 15 '13 at 20:23
  • 1
    SQL Server seems to send it using the "custom display name" of the default profile of SQL Server if you don't specify the "custom display name". It doesn't make sense - should just show e-mail address as "custom display name" is you are changing the "from address". I guess you have to be explicit and tell it what name to use - it is not smart enough to take the e-mail address and make that the "custom display name" – Denis Apr 16 '13 at 14:04

2 Answers2

34

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.)

Aaron Bertrand
  • 272,866
  • 37
  • 466
  • 490
  • I guess if you don't specify the "custom display name" it takes that from some SQL Profile. I would have assumed that if you are setting a "from_address" then if you don't specify the "custom display name" it should put the "from_address" as the "custom display name". It doesn't. – Denis Apr 16 '13 at 14:07
-2

@from_address = 'custom_address@your_domain.com' should work.

Robert Columbia
  • 6,313
  • 15
  • 32
  • 40
Ramanujam Allam
  • 1,300
  • 12
  • 11