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

Forums / Developing with Sitefinity / Notify when news is published

Notify when news is published

7 posts, 0 answered
  1. S R
    S R avatar
    6 posts
    Registered:
    22 Sep 2009
    22 Sep 2009
    Link to this post
    How can I send an email alert when a news is published? On which event can i do this?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    22 Sep 2009
    Link to this post
    Hi soumya R,

    You can subscribe for ContentManager.Executed event in Global.asax file. Then check the module provider and command name and send an email. Below is a 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) 
        var manager = new Telerik.News.NewsManager("News"); 
        if (e.CommandName == "CreateContent" || e.CommandName == "UpdateContent" && manager.Content.Provider.Name == "News"
        { 
            Telerik.Notifications.Newsletters.DataManager dManager = new Telerik.Notifications.Newsletters.DataManager(); 
            IList allSubscribers = dManager.GetSubscribers(); 
            foreach (Telerik.Newsletters.ISubscriber sub in allSubscribers) 
            { 
                // send e- mail 
                Telerik.Notifications.Newsletters.NewsletterManager.SendEmail([toList, body, ssubject, senderName, senderAddress); 
            } 
        } 

    Another approach is described in this KB article. I hope this helps.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. S R
    S R avatar
    6 posts
    Registered:
    22 Sep 2009
    22 Sep 2009
    Link to this post
    I already tried that. The problem is the email is sent whenever a news item gets added irrespective of the publish date. If the publish date is selected as next week, the email should be sent on that day(next week) not today. Is that possible?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    22 Sep 2009
    Link to this post
    Hi soumya R,

    In this case you need to use GetMetaData method to the content item Publication_Date. Then compare it with DateTime.Now. If the date is not the same as DateTime.Now the email will not be sent.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. S R
    S R avatar
    6 posts
    Registered:
    22 Sep 2009
    22 Sep 2009
    Link to this post
    Yes, that will avoid sending emails which are not published today. but then how to send email on that publish date (next week date) ?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    22 Sep 2009
    Link to this post
    Hello soumya R,

    You need to implement scheduled services or logic using Timer/Ajaxify Timer. Sitefinity 4.0 will be shipped with implemented schedule service.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. S R
    S R avatar
    6 posts
    Registered:
    22 Sep 2009
    22 Sep 2009
    Link to this post
    Oh.. ok. Thank you.  will check that out. 
Register for webinar
7 posts, 0 answered