up vote 1 down vote favorite
share [g+] share [fb]

is there possibility to have procedure which sents emails from SQL Server 2008 where I can type sender e-mail address?

Thanks

link|improve this question

76% accept rate
feedback

1 Answer

In SQL Server 2008 use Database Mail, not SQL Mail to send email. SQL Mail is legacy & will be removed in future versions.

You will first need to configure Database Mail

Once a profile has been setup for Database Mail, use the sp_send_dbmail stored procedure.

EDIT:

It works fine for me when i use a different @from_address from what is specified as the email address in the profile. This address is only used when i don't specify a from_address. Code I used to send the email is below:

EXEC msdb.dbo.sp_send_dbmail 
@profile_name='nick '
, @from_address ='Nick Kavadias <nick.kavadias@example.com>'
, @recipients='other_address@example.com'
, @subject='this is a test message'
, @body='t.e.s.t m.e.s.s.a.g.e'

A screen shot of my mail profile settings are below:

alt text

Is the mail being queued? Do you have any logs from your SMTP server?

Check that there aren't any error in the database mail log table msdb.dbo.sysmail_event_log

Failing that, check that it's not something the mail server is disallowing.

link|improve this answer
You are right. But this procedure is not allowing to give sender e-mail or reply to address. I want to achieve this by not adding new e-mail account to Database Mail when every time I want to use different sender e-mail address (or reply to). Is this possible? – GrZeCh Oct 24 '09 at 14:21
database mail is working as expected. I've updated my post – Nick Kavadias Oct 27 '09 at 1:11
feedback

Your Answer

 
or
required, but never shown

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