Thursday, April 12, 2012

send mail to SPGROUP when bulk items added to list


public static void SendEmailsToGroup(string siteUrl, string groupTitle, string emailSubject, string emailBody)
{
    using (var site = new SPSite(siteUrl))
    {
        using (var web = site.OpenWeb())
        {
            var group = web.SiteGroups[groupTitle];
            foreach (var user in group.Users.Cast<SPUser>().Where(usr => !string.IsNullOrEmpty(usr.Email)))
                SPUtility.SendEmail(web, false, false, user.Email, emailSubject, emailBody);
        }
    }
}

No comments:

Post a Comment