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