Previous Topic: Search for a Job Step in a Microsoft SQL Server Agent JobNext Topic: Set Up an Email Notification in the Application


Set Up an Email Notification in the Job Definition

If you want an email notification to send an email when a job reaches a certain condition, such as Fail or Overdue, set up the email notification in the job definition.

Follow these steps:

  1. Open the Application in the Define perspective.

    The Application appears in the workspace.

  2. Right-click the job in the workspace, and select Edit from the pop-up menu.

    The Basic page of the job definition dialog opens.

  3. Click Notifications in the left pane.

    The Notifications page opens in the right pane.

  4. Select the Email tab.
  5. Clear the Use Application-level defaults check box.

    If the Application contains any email notifications, the notifications are copied to the job definition. You can edit or remove a copied notification by selecting the notification and clicking Edit or Remove as required.

    Notes:

  6. Click New to add a notification.

    The New Email Notification dialog opens.

  7. Complete the following fields as appropriate:
    Return code

    (Optional) Specifies an exit code to send the notification on a more specific condition.

    Note: This field applies to only Complete and Fail monitor states.

    Monitor states

    Specifies the job states you can monitor.

    To

    Specifies the recipient's email address.

    Note: After you specify an email address, you must click Add to add the email address to your notification. You can add multiple email addresses.

    Subject

    (Optional) Specifies a customized email subject.

    Notes:

    • To insert the default subject, select the Use default subject check box. The administrator can edit the default subject by modifying the default email template in the Admin perspective.
    • To specify a customized email subject, clear the Use default subject check box. You can insert Application- and job-level built-in symbolic variables into the subject line by right-clicking in the field and selecting the symbolic variable you want to insert from the drop-down menu.
    Message

    (Optional) Adds a customized message to the email.

    Notes:

    • To insert the default message, select the Use default message option button. The administrator can edit the default message by modifying the default email template in the Admin perspective.
    • To add to the default message, select the Attach to default message option button and enter your message. To specify a customized message or override the default message, select the Override default message option button and enter your message. You can insert Application- and job-level built-in symbolic variables into the message by right-clicking in the text box and selecting the symbolic variable you want to insert.
    Attach spool file

    (Optional) Attaches the job's spool file to the email notification.

    Notes:

    • The administrator can configure a shared parameter to limit the size of spool file attachments in email when providing email notifications for failed jobs. For more information about server shared parameters, see the Admin Perspective Help.
    • Not all job types support the Attach spool file option.
  8. Click OK.

    The New Email Notification dialog closes.

  9. Click OK.

    The server sends an email notification whenever the job reaches the monitor state you specified.