Alert mail not received

SP2013


Hello everyone,

Today I’ll talk about a problem that may occur when you set alerts for users.

The error in question is the fact that the user receives the mail saying that an alert was created for him, but he is not receiving alerts generated by adding / modifying element.

One reason could be found if you configure the log to “Verbose” for the “Alert” category.

To configure the logs level, follow this procedure:

  • Go to the central administration
  • Click on the “Monitoring
  • In the “Reporting” section, click on the link “Configure diagnostic logging
  • In the “Event throttling” section, just expand the “SharePoint” section and select “Alerts
  • In the dropdown “Least critical event to report to the track log” choose “Verbose
  • Click ok

Note: This operation does not cause recycle or IISRESET, it can be done live on production farm. By cons when you have finished your test, be sure to return to the previous configuration state (choosing “Reset to default” from the dropdown list, failing which your log files grow very large).

 

This configuration will allow you to see such entries

“Alert for Immediate subscription {GUID}, event ID, USERNAME succeeded permissions check”

If instead you see such entries

Alert for Immediate subscription {GUID}, event ID, user USERNAME failed permissions check

You have your culprit!

Indeed, when sending an alert, a test is made in advance to find out whether the user can log in to the site! If you have not yet given access to the user, although it will receive the email telling him that an alert was created for him, he will not receive the actual alerts!

 

Hope this helps,

Christopher.

Customize alerts

SP2013

Hello everyone,

Today I will talk about a little subtlety in development which I faced recently.

My goal was to change the standard alert message from SharePoint based on custom requirement. For that I had to the code behind to do my test. So I ended up with the implementation of a class inheriting from IAlertNotifyHandler.

Small parenthesis, if you want to do the same, I recommend this article which explains clearly the operation (and I want to thank the author by the way).

http://blogs.msdn.com/b/sharepointdeveloperdocs/archive/2007/12/14/how-to-customizing-alert-emails-using-ialertnotificationhandler.aspx

After a first attempt, I’ve realized that the email received did not looks like the standard mail alert.

In fact, I did not send the entire “header” but just used the “To”. (Again thanks to a passage for the author of this article: http://blogs.msdn.com/b/malag/archive/2008/07/23/alert-emails-not-recognized-by-outlook-as-alert-emails.aspx

Thinking my troubles were ending, I’ve realized that something was also different : the sender’s name!

If we simply use “SPUtility.SendEmail (web, ahp.headers, ahp.body)“, the email address configured in the outgoing mail setup your SharePoint server will be the “sender”, and this is not what is sent by default alerts!

To have exactly the same in your email, you need to change the header “From” as follows.

ahp.headers [“From”] = web.Title + “<” + ahp.headers [“From”] + “>”;

Finally, two things:

1) If you want to test your alerts you have to start the job “Immediate Alerts” for your application via the central administration, “Central Administration -> Monitoring -> review job definition -> Immediate alerts (the one targeting your web application -> run now”. “This job is used for three types of alerts (Immediate, Daily and Weekly)

2) To test your Daily and Weekly alerts, you can easily change the date of mailing via the following PowerShell command

Add-Pssnapin “Microsoft.SharePoint.PowerShell” -ErrorAction SilentlyContinue

$web = Get-SPWeb “yourSiteUrl”

$web.Alerts | select Title,ID,AlertFrequency,User   # this will display every alerts of the web with their ID (used for the next part)

$alert = $web.Alerts | where {$_.ID -eq “PASTE GUID HERE”}

$date=Get-Date

$alert.AlertTime =$date;

$alert.Update();

 

Hope this helps!

 

Christopher