question

eghetto avatar image
eghetto asked

Alert notification not sent!

Dear all, I've set up an alert notification like this: EXEC sys.sp_addmessage @msgnum = 50002 /* INT */ ,@severity = 16 /* SMALLINT */ ,@msgtext = N'My custom error' /* NVARCHAR(255) */ ,@with_log = 'TRUE' /* VARCHAR(5) */ USE [msdb] GO EXEC msdb.dbo.sp_add_alert @name=N'! - My custom error occured', @message_id=50002, @severity=16, @enabled=1, @delay_between_responses=0, @include_event_description_in=1, @notification_message=N'Fix it!', @category_name=N'[Uncategorized]', @job_id=N'00000000-0000-0000-0000-000000000000' GO EXEC sp_add_notification @alert_name = '! - My custom error occured' , @operator_name = 'Operator' , @notification_method = 1 If I try to raise an error like this: RAISERROR(50002, 16, 1); No email is sent. It works fine in our test environment. SQL Server Agent Alert System is configured properly. Thanks for your feedback!
sql-server-agentnotificationalert
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Blackhawk-17 avatar image
Blackhawk-17 answered
I have to ask... does a Database Mail test email work fine? Your Mail Session in SQL Agent is set to Database Mail with a valid profile? You've double-checked that the Alert is enabled?
4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Blackhawk-17 avatar image Blackhawk-17 commented ·
I know I've had this before... try un-checking the enable Mail Session, restart SQL Agent, check enable again and restart once more. No idea why it works but...
1 Like 1 ·
eghetto avatar image eghetto commented ·
Database Mail test email work fine? --> check! valid profile? --> check! Alert is enabled? --> check! I will try to ask my os-server administrator to restart SQL Server Agent, hope that helps...
0 Likes 0 ·
Blackhawk-17 avatar image Blackhawk-17 commented ·
Have you checked the alert's history to see if it "saw" the attempt?
0 Likes 0 ·
eghetto avatar image eghetto commented ·
Yeah - restart did the trick! Thanks!
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.