Email notifications stopped working for a SQL Server Agent job, and this was in the error log:
[264] An attempt was made to send an email when no email session has been established
The cause is that SQL Server Agent has its own mail settings, separate from Database Mail. Configuring Database Mail alone is not enough; Agent has to be told to use it.
To set up SQL Server Agent Mail to use Database Mail:
- In Object Explorer, expand a server.
- Right-click SQL Server Agent and click Properties.
- Click Alert System.
- Select Enable Mail Profile.
- In the Mail system list, select Database Mail.
- In the Mail profile list, select a mail profile for Database Mail.
- Restart SQL Server Agent.
That last step is the one people miss. The settings do not take effect until Agent restarts, so if you make the changes and the notifications still fail, that is usually why.