Customize workflow notifications
Sitefinity's workflow pipeline sends email notifications when content is waiting for approval or when content is rejected. You may want to customize the default workflow notifications. For example, if you want to change the text of the email message, add or remove subscribers, or notify via another channel, such as SMS or the Dashboard. You can do this by injecting your own code into workflow notifications.
This tutorial demonstrates how you can add your code to the workflow notifications and this way, you can send custom email message and add another recipient to the list.
You can do it by descending from WorkflowNotifier and register you new class with the ObjectFactory. The example in the GitHub Custom Workflow Notifier repository is a fully functional class derived from the standard WorkflowNotifier.
This class has 2 overridable methods:
- void SendNotification(WorkflowNotificationContext)
This base class implementation generates the subject and the body of the email and sends the notification to the recipients. In this method, you can trigger your own notification and call the base implementation.
- void BeforeEmailSend(WorkflowNotificationContext context, ref string subjectTemplate, ref string bodyTemplate, ref IDictionary<string, string> tokens, ref IEnumerable<ISubscriberRequest> subscribers)
This method executes upon sending the emails. In this method, you can update the subject and the body template of the email and also add, remove, or change a replacement token. In addition, you can change the list of subscribers or cancel email sending, if you empty the list.