How can I send workflow notifications to all users in a Sitecore role? For instance, the next step in the workflow is for the Legal department to approve or reject. How can I make Sitecore send emails to all users in the Legal Approver role? I'm trying to avoid maintaining a distribution list and would like to grab users' email addresses dynamically.
2 Answers
9
votes
Sitecore security is based on ASP.NET security model. Hence, you can use standard ASP.NET API to obtain users of a certain role:
var users = System.Web.Security.Roles.GetUsersInRole("yourdomain\yourrole");
And later on iterate through the found users and read Email property:
foreach (var user in users)
{
var membershipUser = System.Web.Security.Membership.GetUser(user);
var email = membershipUser.Email;
// use this email to send the message to that user
}
I might be mistaken in syntax details, but I'm sure you can figure it out knowing the general idea.