Home Forums SQL Server 2012 SQL 2012 - General sp_send_dbmail return Command(s) completed successfully. instead of mailsent id RE: sp_send_dbmail return Command(s) completed successfully. instead of mailsent id

  • sp_send_dbmail returns an int output parameter, which you can capture, but you have to do so explicitly.

    [highlight="#ffff11"]declare @TheMailID int[/highlight]

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name='A Profile Specific To Database Mail',

    @recipients='Lowell Izaguirre<lizaguirre@somedomain.com>;',

    @subject = 'Finance SSIS Package Alerts:EDCA to BI360DW',

    @body = @HTMLBody,

    @body_format = 'HTML'[highlight="#ffff11"],

    @mailitem_id = @TheMailID OUTPUT

    PRINT @TheMailID[/highlight]

    /*--results

    Mail queued.

    9005

    */

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!