Reputation: 2276
I have a job with a step that runs the following code:
SELECT * FROM TABLETHATDOESNTEXIST
I have a SQL Server Agent Operator tied to my target email. I've set up the job so that when the job fails, it should email the Operator. However, when I run the job (and watch it fail), the email isn't sent.
I made sure to send a test email via exec sp_send_dbmail
and also via Object Explorer > Database Mail > Send Test E-Mail and that works fine. What else am I missing here?
The job only has 1 step ("FRED" is a table that doesn't exist):
These settings were the defaults I believe:
The notifications tab of the job (the Operator here I selected is the same one everyone because there is currently only 1 Operator in the whole system):
The Operator is pretty simple to set up:
The Operator history shows that an email attempt was made, but I never received anything:
Upvotes: 1
Views: 2623
Reputation: 721
Besides configuring:
Management > Database Mail
SQL Server Agent > Operators
And adding a Notification in Job Properties to send an E-mail to the operator when a Job fails
You also need to configure SQL Server Agent through Properties > Alert System > Mail session
Then it should work, at least it does for me on SQL Server 2016.
Upvotes: 3