Enable email notifications for Tasks list in SharePoint 2013

Leave a Comment
Hello Everyone,

In SharePoint 2013 you will not find that the option to enable email notification for Tasks list. It used to be under List Settings > Advanced Settings > Send e-mail when ownership is assigned? (Yes/No). It is still there for Issues list in SharePoint 2013.

This script(Power shell) and code snippet(SOM) helps you to enable send email notification in SharePoint 2013 Tasks list to assigned to person for creating and editing task.

Once email notification is enabled for the Tasks list, you will get the good old “The content of this item will be sent as an e-mail message to the person or group assigned to the item.” message when creating or editing an item in the list.
Using SOM:
public void EnableEmailTask()
        {
            try
            {
                using (SPSite _oSite = new SPSite("SiteURL"))
                {
                    using (SPWeb _oWeb = _oSite.OpenWeb())
                    {
                        SPList _oList = _oWeb.Lists.TryGetList("Tasks");
                        if (_oList != null)
                        {
                            _oList.EnableAssignToEmail = true;
                            _oList.Update();
                        }
                    }
                }
            }
            catch (Exception)
            {                
                throw;
            }
        }

Using Powershell:
Add-PSSnapin Microsoft.SharePoint.Powershell
$site=Get-SPSite "SiteURL"
$web=$site.OpenWeb()
$list=$web.Lists.TryGetList("Tasks")
if($list -ne $null)
{
   $list.EnableAssignToEmail =$true
   $list.Update()
}

Thanks.

Related Post

0 comments:

Post a Comment