Programmatically create Alert to list


  SPAlert oListAlert = ouser.Alerts.Add();
  oListAlert.AlertType = SPAlertType.List;                                                
  oListAlert.List = olist;                                               
   oListAlert.EventType = SPEventType.All;                                                
   oListAlert.AlertFrequency = SPAlertFrequency.Immediate;                                               
   oListAlert.Title ="My Alert";
   oListAlert.Update(false);
                                             

Comments

  1. i want to set alert for changes to applied those option is there like
    1. Some one change item

    I want to set these one of the option on alert

    ReplyDelete
  2. use the following code

    oListAlert.EventType = SPEventType.Modify;

    ReplyDelete
  3. use this code for an individual item:

    SPListItem oitems = oweb.Lists["List Title"].Items.GetItemById(1);
    SPAlert newAlert = user.Alerts.Add();
    newAlert.AlertType = SPAlertType.Item;
    newAlert.Item = oitems;
    newAlert.EventType = SPEventType.Add;
    newAlert.Update();

    ReplyDelete

Post a Comment

Popular posts from this blog

IRM and the Object Model

This content database has a schema version which is not supported in this farm

Activate and Deactivate Feature through PowerShell