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

Forums / Developing with Sitefinity / Email Notification when comment is posted

Email Notification when comment is posted

13 posts, 0 answered
  1. Paul N
    Paul N avatar
    55 posts
    Registered:
    24 Apr 2010
    14 Sep 2010
    Link to this post
    Hi,

    Is there an easy way to get an email notification every time someone posts a comment on a blog post? At the moment I don't check them every day, so sometimes a comment wont be approved for a few days after being posted. 

    Thanks,
    Paul
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Sep 2010
    Link to this post
    Hello Paul N,

    Yes there is a way. The easiest solution is mapping ListPageDetail.ascx external template and subscribe for Click event of submitBtn

    <asp:Button ID="submitBtn" runat="server" .../>

    and send an email.

    The second option requires creating a custom control that inherits from BlogCommentsList and overriding InitializeControls where you can subscribe for Command event of the button

    this.SubmitButton.Command += this.SubmitButton_Command;

    and send an email. Using the second option you could expose public properties of the control that will be used for setting and updating recipient email, getting exact IContent item etc.

    All the best,
    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. Paul N
    Paul N avatar
    55 posts
    Registered:
    24 Apr 2010
    15 Sep 2010
    Link to this post
    Hi Ivan Dimitrov,

    I think the first option would be best, as it only needs to let me know that a comment has been posted, it doesn't really need to display any dynamic content.

    What exactly would I need to add to the ListPageDetail.ascx file to get a static email when someone posts a comment?

    Thanks again,
    Paul
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Sep 2010
    Link to this post
    Hi Paul N,

    Map the external template mentioned above - How to map an external template, Working with presentation modes and subscribe for Click event of submitBtn

    All the best,
    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
  5. Allen
    Allen avatar
    5 posts
    Registered:
    22 Feb 2011
    22 Feb 2011
    Link to this post
    Hi Ivan,
        Could you give me a detailed example on creating a custom control that inherits from  BlogCommentList.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Feb 2011
    Link to this post
    Hi,

    Please check this post.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  7. Allen
    Allen avatar
    5 posts
    Registered:
    22 Feb 2011
    22 Feb 2011
    Link to this post
    Hi Ivan,

    I would like to send an email to a specific email address when a blog comment is posted.  The "title" of the blog needs to be included in the email.  Can you give me a detailed example?


    Allen
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Feb 2011
    Link to this post
    Hi,

    Inside the global.asax file of the project you can subscribe for Executed event of the ContentManager. There you can get the item ID form the CommandArguments and then its "Title" which is a meta data and send an email

    sample

    void Application_Start(object sender, EventArgs e)
     {
     
         Telerik.Cms.CmsManager.Executed += new EventHandler<Telerik.ExecutedEventArgs>(CmsManager_Executed);
         
     }
     
     void ContentManager_Executing(object sender, Telerik.ExecutingEventArgs e)
     {
         if (e.CommandName == "UpdateContent" || e.CommandName == "CreateContent")
         {
             var manager = new Telerik.Cms.Engine.ContentManager("News");
     
             Telerik.Cms.Engine.IContent c = manager.GetContent(((Telerik.Cms.Engine.Data.CmsContentBase)(e.CommandArguments)).ID);
             c.GetMetaData("Title").ToString();
            // send your email here
     
         }
     }


    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  9. Allen
    Allen avatar
    5 posts
    Registered:
    22 Feb 2011
    01 Mar 2011
    Link to this post
    The following statment
    "Telerik.Cms.Engine.ContentManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(ContentManager_Executing); "

    Is giving me the following error :

    "CS0103: The name 'ContentManager_Executing' does not exist in the current context"

    Any ideas? 

  10. Allen
    Allen avatar
    5 posts
    Registered:
    22 Feb 2011
    01 Mar 2011
    Link to this post
    Sorry!  this statement is giving me the error!


    " Telerik.Cms.CmsManager.Executed += new EventHandler<Telerik.ExecutedEventArgs>(CmsManager_Executed);"
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    02 Mar 2011
    Link to this post
    Hi ,

    You should subscribe for

    Telerik.Cms.Engine.ContentManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(ContentManager_Executing);

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  12. Allen
    Allen avatar
    5 posts
    Registered:
    22 Feb 2011
    02 Mar 2011
    Link to this post
    Thank you for your help sir.  Still having some issues though... Take a look at the following code :

        void ContentManager_Executing(object sender, Telerik.ExecutingEventArgs e)
        {

                  
                
    //            if (e.CommandName == "UpdateContent" || e.CommandName == "CreateContent")
                {
                    Telerik.Cms.Engine.ContentManager manager = new Telerik.Cms.Engine.ContentManager("News");

                    Telerik.Cms.Engine.IContent c = manager.GetContent(((Telerik.Cms.Engine.Data.CmsContentBase)(e.CommandArguments)).ID);
                    c.GetMetaData("Title").ToString();
                    // send your email here
                    
                       

                }

         
        }

    First ->               
    The "Telerik.Cms.Engine.IContent c = manager.GetContent(((Telerik.Cms.Engine.Data.CmsContentBase)(e.CommandArguments)).ID);" statement is returning a casting error.  The casting error is "Unable to cast object of type 'Telerik.Cms.Engine.Data.Comment' to type 'Telerik.Cms.Engine.Data.CmsContentBase".


    Second ->
    When a new post is submitted, what "e.CommandName" value do I need to test for?  Testing for values of  "UpdateContent"  or "CreateContent" does not work.

    Thanks

     
          
      
    Allen
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    02 Mar 2011
    Link to this post
    Hi,

    The comment does not trigger an event. I showed how to access the comment if one of the previous posts here. This code here will work only for content items, but it will not be executed for comments.


    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Register for webinar
13 posts, 0 answered