We help IT Professionals succeed at work.
Get Started

create sharepoint alert

dekempeneer asked
Last Modified: 2012-05-09
I can create an alert for a user, but how can I do it for a security group ?
the code I attach here works for the user, but how do I do it for a GROUP ?
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

namespace Create_Alerts_Sharepoint
    public class Class1

        static void Main(string[] args)
           using (SPSite site = new SPSite("http://shdev01/kp"))
                 using (SPWeb web = site.OpenWeb()) 
                    SPUser user = web.SiteUsers[@"DOMAIN\user"];
              SPAlert newAlert = user.Alerts.Add();
              newAlert.Title = "Latest News";
              newAlert.AlertType = SPAlertType.List;
              newAlert.List = web.Lists["Carrefour"];
              newAlert.EventType = SPEventType.All;
              newAlert.AlertFrequency = SPAlertFrequency.Daily;
                    newAlert.AlertTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 12, 0, 0);
                    newAlert.AlertTime = newAlert.AlertTime.AddDays(1);

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE