I have created sharepoint alerts programmatically. If I check 'manage my alerts' all values are correct such as "Weekly", "Friday", "6:00pm" then I add an item to the list and receive an alert email immediately.

  SPAlert alert = user.Alerts.Add();
  alert.AlertType = SPAlertType.List;
  alert.list = myList;
  alert.AlertTemplate = myList.AlertTemplate;
  alert.User = user;
  alert.EventType = SPEventType.All;
  alert.DeliveryChannels =SPAlertDeliveryChannels.Email;

  // Set Time
  alert.AlertFrequency = SPAlertFrequency.Weekly;
  alert.AlertTime = new DateTime (2012,10,5,18,0,0);

I chose Oct 2012 bcause it has day values of 1=Monday - 5=Friday. I have also tried with April 2013. Still did not work


Try creating an alert manually that works like you want it to. Then fish out the properties with PowerShell (only with SP 2010 though)

$w = get-spweb http://mysites.NotReally.com/sites/ghangas
$w.alerts | ? {$_.User -eq "MyAccountName"}

I have a hunch that you will identify a difference in the alert made in the GUI and the one you are creating.

This is less of an answer than a route to troubleshoot, but it may give you ideas.

  • Than you, this allowed me to see that the SPAlert.properties is empty. Do you know why that is, or how I could get all property keys from the one in powershell? – user13186 Jan 25 '13 at 22:40
  • The only difference seems to be my spalert.properties = {}. But none of the properties that could be there effect frequency – user13186 Jan 26 '13 at 0:04
  • You may consider that the rule is actually working as intended. When you set the date and time for the first run, if it is in the past it will run immediately before setting the datetime for the next run. I recommend using an alternative formula that can calculate the correct date and time of the first run if you are trying to avoid an immediate run. – ghangas Jan 28 '13 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.