Supress Mail queued message

  • After executing following code i get message 'Mail queued'. How do i suppress this message ?
    DECLARE @rc INT
    EXECUTE @rc = msdb.dbo.sp_send_dbmail
      @profile_Name ='Administrator',
      @recipients='somebody@somebody.com,
      @subject = 'Test Emal',
      @body = 'Test Email'

  • Set the parameter @exclude_query_output to 1.

    From the documentation (sp_send_dbmail (Transact-SQL)):

    [ @exclude_query_output= ] exclude_query_output
    Specifies whether to return the output of the query execution in the e-mail message. exclude_query_output is bit, with a default of 0. When this parameter is 0, the execution of the sp_send_dbmail stored procedure prints the message returned as the result of the query execution on the console. When this parameter is 1, the execution of the sp_send_dbmail stored procedure does not print any of the query execution messages on the console.

    Also, I assume you're trying to store the value of the mailitem_id to your variable. Don't use the format EXEC {Variable} = {Stored Procedure};, use the OUTPUT paramter, it's what it's there for. After ficing a couple of syntax error you had, you end up with:

    DECLARE @rc int;
    EXECUTE @rc = msdb.dbo.sp_send_dbmail @profile_name = 'Administrator',
                  @recipients = 'somebody@somebody.com',
                 @subject = 'Test Emal',
                 @body = 'Test Email',
                 @exclude_query_output = 1,
                 @mailitem_id = @rc OUTPUT;

    Any question, please do ask.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Perfect.

  • Thanks a lot

  • This was removed by the editor as SPAM

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply