Email Notification about New Comments - General Discussions - General Discussions - Progress Community
 General Discussions

Email Notification about New Comments

  • Email Notification about New Comments
  • In 3.7, you would subscribe to the "Executing" event in the Global.asax like the below snippet. Is it similar in 4.0?

    public void Application_Start(object sender, EventArgs e)
        Telerik.Cms.Engine.ContentManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(ContentManager_Executing);
     
    public void ContentManager_Executing(object sender, Telerik.ExecutingEventArgs e)
        // Only execute if a comment is being created.
        if (e.CommandName == "CreateComment")
        
            // Code goes here!
        

    (3.7 details taken from here: http://www.sitefinitywatch.com/blog/09-06-16/Email_Notification_about_New_Blog_Comments.aspx)
  • I see there is a property called "EmailAuthor" when I go to "Administration > Settings > Advanced > News > Controls > NewsCommentsFrontend > Views > CommentsDetailsView > CommentsDefinition". Does this have anything to do with it (configuration instead of coding)?
  • Hi bemara57,

    EmailAuthor - gets or sets a value indicating if author of the post will be notified via email when a new comment is submitted. If it is true the author of the post will be notified via email when a new comment is submitted; otherwise false.

    Greetings,
    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
  • Hello Ivan,
    the below code for 3.7, please I need similar to it in 4.x version ?
    public void Application_Start(object sender, EventArgs e)
    Telerik.Cms.Engine.ContentManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(ContentManager_Executing);
    public void ContentManager_Executing(object sender, Telerik.ExecutingEventArgs e)
    // Only execute if a comment is being created.
    if (e.CommandName == "CreateComment")
    // Code goes here!

    Thanks,
    Romany
  • Hello Ivan,
    the below code for 3.7, please I need similar to it in 4.x version ?
    public void Application_Start(object sender, EventArgs e)
    Telerik.Cms.Engine.ContentManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(ContentManager_Executing);
    public void ContentManager_Executing(object sender, Telerik.ExecutingEventArgs e)
    // Only execute if a comment is being created.
    if (e.CommandName == "CreateComment")
    // Code goes here!

    Thanks,
    Romany
  • Hello Romany,

    Can you please check the following blog post.

    Regards,
    Boyan Barnev
    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
  • Dear Boyan,
    I am facing a problem that the event with the same command name called multiple times
    which if I want to send a notification email when a new news item created the email will sent 3 times

    is there a way to solve this problem (in details solution please) ?

    Thanks
    Romany
  • Hi,

    You can override the data provider and its public methods that are called once where needed and then replace the default data provider through configurations.

    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
  • Hello Ivan,

    1- Please can you give me step by step with code, how to override the data provider for "News" to do the following job: when new item created send an email

    2- on the following event in "News" I need to get the newely item created data (title, description) but always all propoerties are empty, why this ?
    void Events_Executed(object sender, Telerik.ExecutedEventArgs e)



    Thanks,
    Romany   
  • Hi,

    Ok, if we are not talking about sending notification when comment is posted, then you can use the workflow by modifying its templates. You should customize NotifyStateChanger EmailText in AnyContentApprovalWorkflow.xamlx. Then you have to map customized templates through Sitefinity/Administration/Settings/Advanced >> Workflows.We use Windows Workflow Foundation and these are the XAML files that you can modify in Visual Studio or another XML editor.

    sample


    public virtual bool NotfiyForNewItem(string name)
          
               EmailSender sen = EmailSender.Get();
               sen.Send(new MailMessage(new MailAddress("mail"), new MailAddress("address")));
               return true;
          

    Have in mind that in standard edition you can have the default workflow only . In the next level - Professional you may have conditional approval steps, safeguards, notifications etc. Here is a related post that you can follow.

    If you want to override the data provider here is the code that you can use.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Sitefinity.Modules.News;
    using Telerik.Sitefinity.Modules.News.Data;
    using Telerik.Sitefinity.News.Model;
    using Telerik.Sitefinity.Security;
    using Telerik.Sitefinity.Model;
    using Telerik.Sitefinity.Localization;
    using Telerik.Sitefinity.Data;
     
    namespace Telerik.Sitefinity.Samples
        public class SitefinityNewsDataProvider : OpenAccessNewsProvider
        
            public override Telerik.Sitefinity.News.Model.NewsItem CreateNewsItem(Guid id)
            
                //return base.CreateNewsItem(id); WE ARE NOT USING THE BASE
     
                var newsItem = new NewsItem(this.ApplicationName, id);
                newsItem.Owner = SecurityManager.GetCurrentUserId();
                ((IDataItem)newsItem).Provider = this;
     
                var securityRoot = this.GetSecurityRoot();
                if (securityRoot != null)
                
                    this.providerDecorator.CreatePermissionInheritanceAssociation(securityRoot, newsItem);
                
                else
                
                    var msg = Res.Get<SecurityResources>().NoSecurityRoot;
                    msg = string.Format(msg, typeof(NewsItem).AssemblyQualifiedName);
                    throw new InvalidOperationException(msg);
                
     
                if (id != Guid.Empty)
                
                    this.GetContext().Add(newsItem);
                
                // HERE SEND YOUR EMAIL. YOU HAVE THE NEWS ITEM OBJECT ADDED TO THE CONTEXT
                return newsItem;
            
        

    When you go to advanced settings you need to expand the News node and open Providers section. There you will find the registration of the default provider and replace it with the custom one that will send an email or make other manipulations with the news item object.

    All the best,
    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
  • Hi Ivan Dimitrov,

    From the above code while creating a news item the function fires "3" times and for each time i am getting different different guid.

    Form the "newsItem" object i cant able to get the "Title","Description" etc. I need to send mail with all those details. Is it possible? If it is possible please provide the sample code for it.

    Thanks
  • Hello,

    The NewsItem has a property Status from which you should be able to identify ContentLifecycleStatus

    - Master
    - Temp
    - Live

    and send the email.

    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
  • Hi Ivan Dimitrov,

    Thanks for your fast reply. In that case all the time i am getting the ContentLifecycleStatus status as "Master" and i am not able to get the "Live" item. Please can you suggest me?

    Here is my code belloe:

    public override Telerik.Sitefinity.News.Model.NewsItem CreateNewsItem(Guid id)
           
                //return base.CreateNewsItem(id); WE ARE NOT USING THE BASE

                var newsItem = new NewsItem(this.ApplicationName, id);
                newsItem.Owner = SecurityManager.GetCurrentUserId();
                ((IDataItem)newsItem).Provider = this;

                var securityRoot = this.GetSecurityRoot();
                if (securityRoot != null)
               
                    this.providerDecorator.CreatePermissionInheritanceAssociation(securityRoot, newsItem);
               
                else
               
                    var msg = Res.Get<SecurityResources>().NoSecurityRoot;
                    msg = string.Format(msg, typeof(NewsItem).AssemblyQualifiedName);
                    throw new InvalidOperationException(msg);
               

                if (id != Guid.Empty)
               
                    this.GetContext().Add(newsItem);

                    if (newsItem.Status == ContentLifecycleStatus.Live)
                   
                        string sTitle = newsItem.Title;
                   
               
                // HERE SEND YOUR EMAIL. YOU HAVE THE NEWS ITEM OBJECT ADDED TO THE CONTEXT
                return newsItem;
           
  • Hi Ivan Dimitrov,

    Is there any solution for the above code?  Please reply me ASAP.


    Thanks