how to temporarily disable email notification while updating items in code?
I am having trouble with temporarily disable email notification while updating items so the system will not send out any unnecessary email. What I am trying to accomplish is that disable alert, updates item, then enable alert back.
SPList taskl开发者_开发百科ist = Web.Lists["Tasks"];
tasklist.EnableAssignToEmail = false; //This property makes sending mail disabled
tasklist.Update();
//Do all the update here
Item["Title"] = "New Title"; Item.update();
tasklist.EnableAssignToEmail = true; //enable email notification
tasklist.Update();
As soon as I enabled back the alert, the changes made in the middle of the code still kick off the alert and send email out.
Anyone have better idea to solve this? Thank you.Does using a SPListItem.SystemUpdate() instead still kick off the alerts?
Did you try DisableEventFiring()/EnableEventFiring() pair of method calls ?
精彩评论