More in this section

Forums / Developing with Sitefinity / Implementing the Sitefinity Notification Service

Implementing the Sitefinity Notification Service

3 posts, 0 answered
  1. Mike
    Mike avatar
    4 posts
    23 Feb 2011
    16 Nov 2012
    Link to this post
    I have a custom module that contains a property called "Departments".  I would like to give my end users the ability to subscribe/unsubscribe to create/update/delete notifications for specific departments.  Is implementing the Sitefinity 5.x Notification Service seen here best way to handle this?  If so does anyone have a working example on how to do this?  I am not sure based on the documentation if I am putting this logic into my module, Global.asax, etc.  If there is a better alternative to accomplish this can you please point me in the right direction.


  2. Slavo
    Slavo avatar
    295 posts
    24 Sep 2012
    20 Nov 2012
    Link to this post
    Hi Mike,

    You are on the right track. The notification service can be used for the purpose. I understand that you're not sure which parts should be done when.

    There are two types of things you are doing when working with the notification service:
    • Creating objects in the database to facilitate sending messages
    • Sending actual messages.

    The first type of actions should be done only once when your module is installed. A good place for this is the Install method. You can create your message templates, profiles and subscription lists there. 
    If your module is dynamic and there's no such method, you can use the Global.asax to create them and check if they already exist to avoid duplication. 

    Once those are ready, you will need to send the actual messages using a message job. Those should be performed whenever the corresponding action is done on the Department object. For example, when a department is deleted, you should send the message for delete notifications.

    In order to perform certain actions whenever an action happens in your module, you can use the Event System. If your module is a dynamic one, you can use the events described in this article:
    Dynamic Modules Events. If it is a static module, you will need to raise the events yourself in your module's code. You can read more about custom events in Implementing custom events.

    I hope this clears the picture.

    All the best,
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Arno
    Arno avatar
    249 posts
    08 Sep 2010
    08 Dec 2012
    Link to this post

    I'm interested in using this service as well. My website is logging errors to a file, and I want the file to be e-mailed to the webmaster every day, and then delete the file. It all works fine with standard .NET classes, but I felt it would be good practice to use the Sitefinity Notification Service instead. Especially since I want to get to know it as I expect I need it for more complex jobs later.

    I converted the second code snippet from to VB:

    Dim ns = Telerik.Sitefinity.Services.SystemManager.GetNotificationService()
    Dim context = New Telerik.Sitefinity.Services.n ServiceContext("myNotificationAccount", "MyCustomModule")
    Dim contextDictionary = New Dictionary(Of String, String)()
    contextDictionary.Add("MergeData.Time", DateTime.UtcNow.ToString())
    Dim profileName = "DefaultSmtpProfile"
    'Name of an existing profile
    Dim subjectTemplate = "Test notification"
    Dim bodyTemplate = "Hi {|Subscriber.FirstName|} {|Subscriber.LastName|}, the time is: {|MergeData.Time|}"
    Dim tmpl = New MessageTemplateRequestProxy() With { _
        .Subject = subjectTemplate, _
        .BodyHtml = bodyTemplate _
    Dim subscriber As ISubscriberRequest = New SubscriberRequestProxy() With { _
        .Email = "", _
        .FirstName = "David", _
        .LastName = "Daniels", _
        .ResolveKey = "unique-identifier-in-the-specified-context" _
    'Creates and persists the subscription list
    Dim subscriptionList As ISubscriptionListRequest = New SubscriptionListRequestProxy() With { _
        .Title = "SampleList", _
        .ResolveKey = "unique-identifier-in-the-specified-context", _
        .Description = "Sample subscirption lsit description." _
    Dim subscriptionListId As Guid = ns.CreateSubscriptionList(context, subscriptionList)
    'Subscribe the subscriber to the newly created subscription list
    ns.Subscribe(context, subscriptionListId, subscriber)
    'Create a message job
    Dim job As IMessageJobRequest = New MessageJobRequestProxy() With { _
        .MessageTemplate = tmpl, _
        .SubscriptionsListId = subscriptionListId, _
        .SenderProfileName = profileName _
    'Send the message job for processing
    Dim messageJobId = ns.SendMessage(context, job, contextDictionary)

    Now Visual Studio complains about non defined types, e.g. for ServiceContext, MessageTemplateRequestProxy and ISubscriberRequest. I can't find ServiceContext anywhere in the API reference or through .NET Reflector. Is this code up to date for Sitefinity 5.2? Has anyone used it successfully?
3 posts, 0 answered