sp_send_dbmail "Mail Queued." Message

I have an After Update Trigger specified on a database table to notify specific users via email when certain customer values are modified. (This is a HACK / Workaround for functionality that doesn't exsist in the product.)

I had be usingxp_sendmail without a problem. I recently upgraded the database server to SQL2005 and wanted to trysp_send_dbmail. (I was interested in the asynch and the non-MAPI nature of Database Mail.)

This is the new code:

EXEC @retval= msdb.dbo.sp_send_dbmail

@recipients= @rec,

@blind_copy_recipients= @bcc,

@subject='Important Customer Information Change',

@body= @body

This is the old code:

EXEC @retval= master.dbo.xp_sendmail

@recipients= @rec,

@blind_copy_recipients= @bcc,

@subject='Important Customer Information Change',

@message= @body

The problem now is that the application reports an update failure because thesp_send_dbmailreturn the message"Mail Queued."

I don't know if there's a way to suppress this message or not. Or some other way to indicate that "all is well" even though the stored procedure returned a message.

Thanks in advance.

[2857 byte] By [DerrickPowell] at [2008-1-10]
# 1
From the information in the BOL topic, this message cannot be avoided or suppressed. I would encourage you to file a bug using http://lab.msdn.microsoft.com/productfeedback for an option to suppress unnecessary output. The return code from the stored procedure indicates the success or failure of the operation anyway.
The obvious solution now is to modify the application code to ignore informational messages and not treat them as error conditions.
# 2
Set @exclude_query_output paramter to 1, this will surpress the print message. Zed
Zeddys at 2007-10-3 > top of Msdn Tech,SQL Server,Transact-SQL...
# 3

I let this go for quite some time. I submitted a bug to Microsoft but the functionality of this SP was already set and they weren't willing to change it after RTM. (I can totally understand that.) Now that we are using all SQL 2005 servers this is more important.

Thanks Zeddys for being more persistant than I was on trying different parameters to see what worked. I am going to see if I can post a workaround on the Microsoft bug site...

Thanks again.

DerrickPowell at 2007-10-3 > top of Msdn Tech,SQL Server,Transact-SQL...
# 4

Thanks Zed,

I had the same problem and your suggestion worked for me.

ShibuShaji at 2007-10-3 > top of Msdn Tech,SQL Server,Transact-SQL...
# 5
the parameter @exclude_query_output = 1 works for a near identical scenario as the original poster. added trigger mail functionality to their product, and the application was returning Mail Queued as an error.

this suggestion makes everything work great!
striving at 2008-2-18 > top of Msdn Tech,SQL Server,Transact-SQL...

SQL Server

Site Classified