Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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 or How do I specify a "custom" FROM_ADDRESS?

share|improve this question
1  
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 at 20:23
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 at 14:04

1 Answer

up vote 2 down vote accepted

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

share|improve this answer
that did it! Thanks! – Denis Apr 16 at 14:01
@Denis great! Which part? – Aaron Bertrand Apr 16 at 14:03
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 at 14:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.