+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Modify News Module to send an email

Modify News Module to send an email

5 posts, 0 answered
  1. Bhavz
    Bhavz avatar
    3 posts
    Registered:
    17 Nov 2010
    18 Nov 2010
    Link to this post
    Hi All

    I am new to Sitefinity, and I have to say its been really easy for me to get up to speed with the way things are done and how I am able to build and manage sites.

    I am trying to modify the news module so I can get the Sitefinity site to send out an email to a list of email addresses I have stored in the database. Every time a news item is added and published, I would like an email to be sent out to the list of subscribers notifying them to visit the site to read about the new news item.

    Could anyone help steer me in the right direction?

    Thanks.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    18 Nov 2010
    Link to this post
    Hello Bhavz,

    Thank you for your feedback.

    To achieve your goal you can subscribe for ContentManage.Executed static event in Global.asax Application_Start and, get the content item and send an email to your users

    below is  sample code

    void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup
        Telerik.Cms.Engine.ContentManager.Executed += new EventHandler<Telerik.ExecutedEventArgs>(ContentManager_Executed);
    }
     
    void ContentManager_Executed(object sender, Telerik.ExecutedEventArgs e)
    {
        if (e.CommandName == "UpdateContent" || e.CommandName == "CreateContent", || "DeleteContent")
        {
            var providerName = (e.Data as Telerik.Cms.Engine.Data.CmsContentBase).ProviderName;
            if (providerName == "News")
            {
                var itemID = e.ItemID;
                var itemName = (e.Data as Telerik.Cms.Engine.Data.CmsContentBase).Name;
                 // send an email here
            }
        }
    }

    If you are using workflow, please take a look at How to notify approvers when a News item is sent for approval

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Bhavz
    Bhavz avatar
    3 posts
    Registered:
    17 Nov 2010
    19 Nov 2010
    Link to this post
    Hi Ivan

    Thanks for your response. The code you provided has allowed me to complete the functionality required.
  4. Eric
    Eric avatar
    4 posts
    Registered:
    13 Jun 2011
    13 Jun 2011
    Link to this post
    Hi all

    Is there a way to refine this method to accommodate the publication date?

    Perhaps this piece of content isn't supposed to be published till tomorrow..... we don't necessarily want this email being sent out on the "CreateContent" or "UpdateContent"..... but when it hits that publication time.

    Any help is appreciated.

    Thanks,
    Eric
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    13 Jun 2011
    Link to this post
    Hi,

    You could implement scheduled services

    http://www.sitefinity.com/blogs/ivandimitrov/ivanposts/10-01-22/implementing_scheduled_services_in_sitefinity_3_x.aspx


    Kind regards,
    Ivan Dimitrov
    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
Register for webinar
5 posts, 0 answered