Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 How to use sp_send_dbmail without a profile name?

Author  Topic 

CharleyDC5
Starting Member

1 Post

Posted - 2011-04-01 : 12:54:02
Hi folks,

I am currently migrating from MSSQL 2000 to MSSQL 2008.

Before, we were using the master.dbo.sp_send_cdosysmail stored procedure to send an email from a Web application. I discovered that this stored procedure does not work anymore in MSSQL 2008. I need to use msdb.dbo.sp_send_dbmail, which is quite similar to the old one.

Everything works fine now but I found a little glitch that I would like to fix, if possible.

I created a profile under Management > Database mail

When I use the following code:
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'MYPROFILE',
@from_address = 'MY_EMAIL_ADDRESS',
@recipients = 'MY_EMAIL_ADDRESS',
@subject = 'test',
@body_format = 'HTML',
@body = '123456789'

I receive an email, but the sender's name is the one specified in the profile.
For instance :
From : MYPROFILE NAME [MY_EMAIL_ADDRESS]
To : My name
Subject : test
Message content : 123456789

What I would like to see is:
From : My name(or the user's name) [MY_EMAIL_ADDRESS] OR simply MY_EMAIL_ADDRESS
To : My name
Subject : test
Message content : 123456789

... just like the good old way I was used to use in MSSQL 2000.

I also have another situation that is quite annoying. Let's say the email is sent to a mailbox using that same stored procedure. The Exchange mailbox is sending back an acknowledgement receipt to the email address specified in the default Database mail profile, which is WRONG! I want the acknowledgement receipt to be sent to the client that submitted the service request from the Web.

Any thoughts?

Thank you
   

- Advertisement -