How to temporarily disable email notification when updating code elements?

I am having problems temporarily disabling email notification when updating items so that the system does not send an unnecessary email. What I'm trying to do is turn off the alert, update the item, and then turn on the alert.

SPList tasklist = Web.Lists ["Tasks"];

tasklist.EnableAssignToEmail = false; // This property makes sending mail disabled.

tasklist.Update ();

// Do the whole update here

Item ["Name"] = "New Name"; Item.update ();

tasklist.EnableAssignToEmail = true; // enable email notification

tasklist.Update ();

As soon as I turned on the warning, the changes made in the middle of the code still trigger the warning and send the email.
Anyone have an idea to solve this problem? Thanks.

+4
source share
2 answers

Does it use SPListItem. Does SystemUpdate () fire warnings instead?

+5
source

Have you tried disabling a couple of calls to the DisableEventFiring () / EnableEventFiring () method?

0
source

All Articles