Step1 : create an operator who will receive notifications.

Use msdb
If Not Exists(Select name From msdb.dbo.sysoperators
Where name = N'DBAdministrator')
Exec msdb.dbo.sp_add_operator @name=N'DBAdministrator',

-- Step2 :

create an alert that triggers when a lack of resources.

If Not Exists(Select name From msdb.dbo.sysalerts
Where name = N'Lack of resources')
Exec msdb.dbo.sp_add_alert @name=N'Lack of resources',

-- Step3 :

notify the operator created previously.

If Not Exists(Select notifications.notification_method,,
 From msdb.dbo.sysnotifications as notifications
 inner join msdb.dbo.sysalerts as alerts on notifications.alert_id =
 inner join msdb.dbo.sysoperators as operators on notifications.operator_id =
 Where = N'Lack of resources'
 and = N'DBAdministrator'
 and  notification_method = 1)
 Exec msdb.dbo.sp_add_notification @alert_name=N'Lack of resources',
 @operator_name=N'DBAdministrator', @notification_method = 1

-- Step 4 :

trigger alert.

Use [DataBase]

Do not forget to use (With Log).

RaisError (N'An error occurred Severity 17: insufficient resources ! ', 17, 1)
With Log

 Step 5 :

check your email.


If the operator does not receive an e-mail
Test database mail by sending a test e-mail to the operator's e-mail address.
Make sure you restarted SQL Agent and it is running.