Email notifications to all subscribers when the new document is published
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I want to be able to send email notifications to list of subscribed users (<500 users) registered under membership provider as soon as a new document is published to content delivery.
This can be achieved in a number of ways in Sitecore.
What would be the best way to send this notification without affecting/slowing over all performance of application/publish pipeline/document library.
- Use workflow
- Subscribe to publish-related events
- Add code into the 'publish' pipeline
pipelines
add a comment |Â
up vote
3
down vote
favorite
I want to be able to send email notifications to list of subscribed users (<500 users) registered under membership provider as soon as a new document is published to content delivery.
This can be achieved in a number of ways in Sitecore.
What would be the best way to send this notification without affecting/slowing over all performance of application/publish pipeline/document library.
- Use workflow
- Subscribe to publish-related events
- Add code into the 'publish' pipeline
pipelines
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I want to be able to send email notifications to list of subscribed users (<500 users) registered under membership provider as soon as a new document is published to content delivery.
This can be achieved in a number of ways in Sitecore.
What would be the best way to send this notification without affecting/slowing over all performance of application/publish pipeline/document library.
- Use workflow
- Subscribe to publish-related events
- Add code into the 'publish' pipeline
pipelines
I want to be able to send email notifications to list of subscribed users (<500 users) registered under membership provider as soon as a new document is published to content delivery.
This can be achieved in a number of ways in Sitecore.
What would be the best way to send this notification without affecting/slowing over all performance of application/publish pipeline/document library.
- Use workflow
- Subscribe to publish-related events
- Add code into the 'publish' pipeline
pipelines
pipelines
edited 4 hours ago


Peter Prochazka
3,8131734
3,8131734
asked 6 hours ago
Umar D
548
548
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
I would use Workflow in your case.
You need to create and assign different workflow for document templates on their standard values to make this working.
There is an "Email action" OOTB that you can use in your workflow to send emails but you need to create custom class to send emails to your subscribed list.
Just add this action after Auto Publish to your workflow like this and fill in the fields:
Insert text into Message field. Something like:
We have new document for for! Check it out here: $itemUrl$
Change Type field especially to your custom class definition:
Use Your_namespace_goes_here.SubscribersEmailAction, Your_assembly_name_goes_here notation in Type field. SubscribersEmailAction is name of class below.
SubscribersEmailAction Class could be something similar to this code:
using System.Net.Mail;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Workflows.Simple;
using Sitecore.Links;
namespace Your_namespace_goes_here
public class SubscribersEmailAction
public void Process(WorkflowPipelineArgs args)
Assert.ArgumentNotNull(args, "args");
var processorItem = args.ProcessorItem;
if (processorItem == null)
return;
var commandItem = processorItem.InnerItem;
var fullPath = commandItem.Paths.FullPath;
var from = GetText(commandItem, "from", args);
var to = GetText(commandItem, "to", args);
var mailServer = GetText(commandItem, "mail server", args);
var subject = GetText(commandItem, "subject", args);
var message = GetText(commandItem, "message", args);
Error.Assert(to.Length > 0, "The 'To' field is not specified in the mail action item: " + fullPath);
Error.Assert(from.Length > 0, "The 'From' field is not specified in the mail action item: " + fullPath);
Error.Assert(subject.Length > 0, "The 'Subject' field is not specified in the mail action item: " + fullPath);
var smtpClient = string.IsNullOrWhiteSpace(mailServer)
? new SmtpClient()
: new SmtpClient(mailServer);
smtpClient.Send(new MailMessage(from, to)
Subject = subject,
Body = message
);
public string GetText(Item commandItem, string field, WorkflowPipelineArgs args)
var text = commandItem[field];
return text.Length > 0 ? ReplaceVariables(text, args) : string.Empty;
private static string ReplaceVariables(string text, WorkflowPipelineArgs args)
text = text.Replace("$itemUrl$", MediaUrl(args.DataItem));
return text;
private static string MediaUrl(Item item)
if (item == null) return string.Empty;
if (!item.Paths.IsMediaItem) return string.Empty;
var theURL = Sitecore.Resources.Media.MediaManager.GetMediaUrl(item);
mediaUrl = Sitecore.Resources.Media.HashingUtils.ProtectAssetUrl(theURL);
return mediaUrl;
Code inspired by this blog post: https://jeffreyrondeau.wordpress.com/2015/02/25/extending-sitecore-workflow-email-action/
You need to tweak a bit the code because you need to replace "To" field with email addresses from your subscribers list.
1
SPE can also be used!
– Michael West
1 hour ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
I would use Workflow in your case.
You need to create and assign different workflow for document templates on their standard values to make this working.
There is an "Email action" OOTB that you can use in your workflow to send emails but you need to create custom class to send emails to your subscribed list.
Just add this action after Auto Publish to your workflow like this and fill in the fields:
Insert text into Message field. Something like:
We have new document for for! Check it out here: $itemUrl$
Change Type field especially to your custom class definition:
Use Your_namespace_goes_here.SubscribersEmailAction, Your_assembly_name_goes_here notation in Type field. SubscribersEmailAction is name of class below.
SubscribersEmailAction Class could be something similar to this code:
using System.Net.Mail;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Workflows.Simple;
using Sitecore.Links;
namespace Your_namespace_goes_here
public class SubscribersEmailAction
public void Process(WorkflowPipelineArgs args)
Assert.ArgumentNotNull(args, "args");
var processorItem = args.ProcessorItem;
if (processorItem == null)
return;
var commandItem = processorItem.InnerItem;
var fullPath = commandItem.Paths.FullPath;
var from = GetText(commandItem, "from", args);
var to = GetText(commandItem, "to", args);
var mailServer = GetText(commandItem, "mail server", args);
var subject = GetText(commandItem, "subject", args);
var message = GetText(commandItem, "message", args);
Error.Assert(to.Length > 0, "The 'To' field is not specified in the mail action item: " + fullPath);
Error.Assert(from.Length > 0, "The 'From' field is not specified in the mail action item: " + fullPath);
Error.Assert(subject.Length > 0, "The 'Subject' field is not specified in the mail action item: " + fullPath);
var smtpClient = string.IsNullOrWhiteSpace(mailServer)
? new SmtpClient()
: new SmtpClient(mailServer);
smtpClient.Send(new MailMessage(from, to)
Subject = subject,
Body = message
);
public string GetText(Item commandItem, string field, WorkflowPipelineArgs args)
var text = commandItem[field];
return text.Length > 0 ? ReplaceVariables(text, args) : string.Empty;
private static string ReplaceVariables(string text, WorkflowPipelineArgs args)
text = text.Replace("$itemUrl$", MediaUrl(args.DataItem));
return text;
private static string MediaUrl(Item item)
if (item == null) return string.Empty;
if (!item.Paths.IsMediaItem) return string.Empty;
var theURL = Sitecore.Resources.Media.MediaManager.GetMediaUrl(item);
mediaUrl = Sitecore.Resources.Media.HashingUtils.ProtectAssetUrl(theURL);
return mediaUrl;
Code inspired by this blog post: https://jeffreyrondeau.wordpress.com/2015/02/25/extending-sitecore-workflow-email-action/
You need to tweak a bit the code because you need to replace "To" field with email addresses from your subscribers list.
1
SPE can also be used!
– Michael West
1 hour ago
add a comment |Â
up vote
3
down vote
I would use Workflow in your case.
You need to create and assign different workflow for document templates on their standard values to make this working.
There is an "Email action" OOTB that you can use in your workflow to send emails but you need to create custom class to send emails to your subscribed list.
Just add this action after Auto Publish to your workflow like this and fill in the fields:
Insert text into Message field. Something like:
We have new document for for! Check it out here: $itemUrl$
Change Type field especially to your custom class definition:
Use Your_namespace_goes_here.SubscribersEmailAction, Your_assembly_name_goes_here notation in Type field. SubscribersEmailAction is name of class below.
SubscribersEmailAction Class could be something similar to this code:
using System.Net.Mail;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Workflows.Simple;
using Sitecore.Links;
namespace Your_namespace_goes_here
public class SubscribersEmailAction
public void Process(WorkflowPipelineArgs args)
Assert.ArgumentNotNull(args, "args");
var processorItem = args.ProcessorItem;
if (processorItem == null)
return;
var commandItem = processorItem.InnerItem;
var fullPath = commandItem.Paths.FullPath;
var from = GetText(commandItem, "from", args);
var to = GetText(commandItem, "to", args);
var mailServer = GetText(commandItem, "mail server", args);
var subject = GetText(commandItem, "subject", args);
var message = GetText(commandItem, "message", args);
Error.Assert(to.Length > 0, "The 'To' field is not specified in the mail action item: " + fullPath);
Error.Assert(from.Length > 0, "The 'From' field is not specified in the mail action item: " + fullPath);
Error.Assert(subject.Length > 0, "The 'Subject' field is not specified in the mail action item: " + fullPath);
var smtpClient = string.IsNullOrWhiteSpace(mailServer)
? new SmtpClient()
: new SmtpClient(mailServer);
smtpClient.Send(new MailMessage(from, to)
Subject = subject,
Body = message
);
public string GetText(Item commandItem, string field, WorkflowPipelineArgs args)
var text = commandItem[field];
return text.Length > 0 ? ReplaceVariables(text, args) : string.Empty;
private static string ReplaceVariables(string text, WorkflowPipelineArgs args)
text = text.Replace("$itemUrl$", MediaUrl(args.DataItem));
return text;
private static string MediaUrl(Item item)
if (item == null) return string.Empty;
if (!item.Paths.IsMediaItem) return string.Empty;
var theURL = Sitecore.Resources.Media.MediaManager.GetMediaUrl(item);
mediaUrl = Sitecore.Resources.Media.HashingUtils.ProtectAssetUrl(theURL);
return mediaUrl;
Code inspired by this blog post: https://jeffreyrondeau.wordpress.com/2015/02/25/extending-sitecore-workflow-email-action/
You need to tweak a bit the code because you need to replace "To" field with email addresses from your subscribers list.
1
SPE can also be used!
– Michael West
1 hour ago
add a comment |Â
up vote
3
down vote
up vote
3
down vote
I would use Workflow in your case.
You need to create and assign different workflow for document templates on their standard values to make this working.
There is an "Email action" OOTB that you can use in your workflow to send emails but you need to create custom class to send emails to your subscribed list.
Just add this action after Auto Publish to your workflow like this and fill in the fields:
Insert text into Message field. Something like:
We have new document for for! Check it out here: $itemUrl$
Change Type field especially to your custom class definition:
Use Your_namespace_goes_here.SubscribersEmailAction, Your_assembly_name_goes_here notation in Type field. SubscribersEmailAction is name of class below.
SubscribersEmailAction Class could be something similar to this code:
using System.Net.Mail;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Workflows.Simple;
using Sitecore.Links;
namespace Your_namespace_goes_here
public class SubscribersEmailAction
public void Process(WorkflowPipelineArgs args)
Assert.ArgumentNotNull(args, "args");
var processorItem = args.ProcessorItem;
if (processorItem == null)
return;
var commandItem = processorItem.InnerItem;
var fullPath = commandItem.Paths.FullPath;
var from = GetText(commandItem, "from", args);
var to = GetText(commandItem, "to", args);
var mailServer = GetText(commandItem, "mail server", args);
var subject = GetText(commandItem, "subject", args);
var message = GetText(commandItem, "message", args);
Error.Assert(to.Length > 0, "The 'To' field is not specified in the mail action item: " + fullPath);
Error.Assert(from.Length > 0, "The 'From' field is not specified in the mail action item: " + fullPath);
Error.Assert(subject.Length > 0, "The 'Subject' field is not specified in the mail action item: " + fullPath);
var smtpClient = string.IsNullOrWhiteSpace(mailServer)
? new SmtpClient()
: new SmtpClient(mailServer);
smtpClient.Send(new MailMessage(from, to)
Subject = subject,
Body = message
);
public string GetText(Item commandItem, string field, WorkflowPipelineArgs args)
var text = commandItem[field];
return text.Length > 0 ? ReplaceVariables(text, args) : string.Empty;
private static string ReplaceVariables(string text, WorkflowPipelineArgs args)
text = text.Replace("$itemUrl$", MediaUrl(args.DataItem));
return text;
private static string MediaUrl(Item item)
if (item == null) return string.Empty;
if (!item.Paths.IsMediaItem) return string.Empty;
var theURL = Sitecore.Resources.Media.MediaManager.GetMediaUrl(item);
mediaUrl = Sitecore.Resources.Media.HashingUtils.ProtectAssetUrl(theURL);
return mediaUrl;
Code inspired by this blog post: https://jeffreyrondeau.wordpress.com/2015/02/25/extending-sitecore-workflow-email-action/
You need to tweak a bit the code because you need to replace "To" field with email addresses from your subscribers list.
I would use Workflow in your case.
You need to create and assign different workflow for document templates on their standard values to make this working.
There is an "Email action" OOTB that you can use in your workflow to send emails but you need to create custom class to send emails to your subscribed list.
Just add this action after Auto Publish to your workflow like this and fill in the fields:
Insert text into Message field. Something like:
We have new document for for! Check it out here: $itemUrl$
Change Type field especially to your custom class definition:
Use Your_namespace_goes_here.SubscribersEmailAction, Your_assembly_name_goes_here notation in Type field. SubscribersEmailAction is name of class below.
SubscribersEmailAction Class could be something similar to this code:
using System.Net.Mail;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Workflows.Simple;
using Sitecore.Links;
namespace Your_namespace_goes_here
public class SubscribersEmailAction
public void Process(WorkflowPipelineArgs args)
Assert.ArgumentNotNull(args, "args");
var processorItem = args.ProcessorItem;
if (processorItem == null)
return;
var commandItem = processorItem.InnerItem;
var fullPath = commandItem.Paths.FullPath;
var from = GetText(commandItem, "from", args);
var to = GetText(commandItem, "to", args);
var mailServer = GetText(commandItem, "mail server", args);
var subject = GetText(commandItem, "subject", args);
var message = GetText(commandItem, "message", args);
Error.Assert(to.Length > 0, "The 'To' field is not specified in the mail action item: " + fullPath);
Error.Assert(from.Length > 0, "The 'From' field is not specified in the mail action item: " + fullPath);
Error.Assert(subject.Length > 0, "The 'Subject' field is not specified in the mail action item: " + fullPath);
var smtpClient = string.IsNullOrWhiteSpace(mailServer)
? new SmtpClient()
: new SmtpClient(mailServer);
smtpClient.Send(new MailMessage(from, to)
Subject = subject,
Body = message
);
public string GetText(Item commandItem, string field, WorkflowPipelineArgs args)
var text = commandItem[field];
return text.Length > 0 ? ReplaceVariables(text, args) : string.Empty;
private static string ReplaceVariables(string text, WorkflowPipelineArgs args)
text = text.Replace("$itemUrl$", MediaUrl(args.DataItem));
return text;
private static string MediaUrl(Item item)
if (item == null) return string.Empty;
if (!item.Paths.IsMediaItem) return string.Empty;
var theURL = Sitecore.Resources.Media.MediaManager.GetMediaUrl(item);
mediaUrl = Sitecore.Resources.Media.HashingUtils.ProtectAssetUrl(theURL);
return mediaUrl;
Code inspired by this blog post: https://jeffreyrondeau.wordpress.com/2015/02/25/extending-sitecore-workflow-email-action/
You need to tweak a bit the code because you need to replace "To" field with email addresses from your subscribers list.
answered 3 hours ago


Peter Prochazka
3,8131734
3,8131734
1
SPE can also be used!
– Michael West
1 hour ago
add a comment |Â
1
SPE can also be used!
– Michael West
1 hour ago
1
1
SPE can also be used!
– Michael West
1 hour ago
SPE can also be used!
– Michael West
1 hour ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f14810%2femail-notifications-to-all-subscribers-when-the-new-document-is-published%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password