Last active
November 10, 2018 09:54
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NotifySubmit | |
{ | |
public void Process(WorkflowPipelineArgs args) | |
{ | |
var contentItem = args.DataItem; | |
var currentUser = Sitecore.Context.User; | |
Item ownersRoot = SiteConfiguration.GetOwnerssRootItem();//gets the root item of owners so we can traverse it later | |
var comment = args.CommentFields.Values.ElementAt(0);//gets the comment add this to the email | |
//############## Build you Email content #######################333 | |
// to use the send mail code below you should add emailbody, fromemail and subject | |
//I would recommend to add direct links to content editor/experience editor | |
// /sitecore/shell/Applications/Content Editor.aspx?fo= + contentItem.ID | |
// /?sc_mode=edit&sc_itemid=" + contentItem.ID | |
Log.Info("NotifySubmit - User request from: " + currentUser.Name, this); | |
foreach (Item owner in ownersRoot.Children) | |
{ | |
Role editorRole = Role.FromName(owner["Editor Role"]); | |
if (currentUser.IsInRole(editorRole)) | |
{ | |
var users = System.Web.Security.Roles.GetUsersInRole(owner["Publisher Role"]); | |
foreach (var user in users)//we travers all the users who has the correct role and send them an notification email | |
{ | |
var membershipUser = System.Web.Security.Membership.GetUser(user); | |
var email = membershipUser.Email; | |
if (email != null) | |
{ | |
var emailMessage = new MailMessage(fromEmail, email, subject, emailBody); | |
emailMessage.IsBodyHtml = true; | |
MainUtil.SendMail(emailMessage); | |
Log.Info("NotifySubmit - mail sendt to: " + email, this); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment