Sending email notification using SQL agent step/p

  •  

    I am trying to send email to specific people when the jobs completes. the idea is to add the step in the job with the below code.

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'TEST Alert', -- Do I have to create first using DB mail?

    @recipients = 'Email of the person or people you want to send',

    @from_address = ',' -- I am wondering what this should be..?

    @subject = 'TEST Scripts',

    @body = 'The following scripts have been run successfully'

    Error : Executed as user: ***. profile name is not valid [SQLSTATE 42000] (Error 14607). The step failed.

     

  • You can setup the agent job to send notification on completion - you don't have to add a job step and use sp_send_dbmail.  Database Mail does need to be setup and configured - and SQL Agent configured to use Database Mail though.

    If you must add a job step:

    @profile_name is required - and you must setup the profile in database mail.

    @from_address can be any address string you want - and it does not have to be a valid address.

     

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

Viewing 2 posts - 1 through 1 (of 1 total)

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