Notification of Blog Comment

Posted by Community Admin on 03-Aug-2018 20:12

Notification of Blog Comment

All Replies

Posted by Community Admin on 18-Nov-2011 00:00

Is there a way for Sitefinity to send an email notification out when a comment is posted to a blog entry?

Posted by Community Admin on 19-Nov-2011 00:00

Sadly no...a notification system should be in early 2012...I've been pestering them for that one for a while

Sorry :/

The only thing we have right now is a marketplace addon which adds FORM submission notifications.

Posted by Community Admin on 21-Feb-2012 00:00

Is this part of Sitefinity yet?

Thanks,
Gary

Posted by Community Admin on 23-Feb-2012 00:00

Hello,

It is not available out of the box, but can be done with this customization.
Create a class in your solution and crete a custom comment class as in the sample below.

 For blog comments:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using Telerik.Sitefinity.Configuration;
using Telerik.Sitefinity.Services;
using System.Text;
using Telerik.Sitefinity.Web.Mail;
using System.ComponentModel;
  
namespace SitefinityWebApp
    public class CustomComments : Telerik.Sitefinity.Modules.GenericContent.Web.UI.Views.CommentsDetailsView
    
        protected override void SubmitComment()
        
            base.SubmitComment();
            var smtpSettings = Config.Get<SystemConfig>().SmtpSettings;
            MailMessage message = new MailMessage();
            message.From = new MailAddress(smtpSettings.DefaultSenderEmailAddress);
            message.To.Add(new MailAddress("stanislav.velikov@telerik.com"));
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("You have one new form response on  form. The response is sent from IP address");
            message.Subject = "Forms notification";
            message.Body = sb.ToString();
            message.IsBodyHtml = true;
            message.BodyEncoding = Encoding.Unicode;
            message.SubjectEncoding = Encoding.Unicode;
            EmailSender.Get().Send(message);
        
    

Go to Administration->Settings->Advanced->ContentView->Controls->BlogCommentsFrontend->Views->CommentsDetailView-> find the textbox ViewType and enter in it the namespace.class of the class created (in my case SitefinityWebApp.CustomComments ).
This will send email for  blog comments only. Following the same pattern the same class can be used to send comments for news, events

To receive the e-mail you mut have valid SMTP settings configured in Administration->Settings->Advanced->System->SMTP

Regards,
Stanislav Velikov
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

Posted by Community Admin on 15-May-2012 00:00

Hi Stanislav Velikov,

While posting a comment the event get fired, but unfortunately i am not able to get the "Commented" information ex:(Name,Email,Comment Text). I need to send a mail with Commented information. Can u please help me around this?


Thanks

Posted by Community Admin on 16-May-2012 00:00

Hi Stanislav Velikov,

At the time of submittion,  the "Comment" form not get validated. After the event fires on server side the validation get fired. Is this a bug?

Posted by Community Admin on 26-Jun-2012 00:00

Hi Mari,

Did you work out how to get the content of the form (name, email, comments)? If so can you share the code please?

(or failing that can anyone help?)

thanks
Pete

Posted by Community Admin on 14-May-2013 00:00

This should retrieve the content of the form

protected override void SubmitComment()
        var content = this.ContentControl.Value.ToString();
        var authorName = this.Page.Server.HtmlEncode(this.AuthorNameControl.Value.ToString());          
        base.SubmitComment();
            
 

- Nidhi

Posted by Community Admin on 14-May-2013 00:00

Hi,

A better solution is to subscribe to sitefinity event when a comment has been created (here is the documentation for comments events) the submitted comment data is in the event arguments for the event.

Greetings,
Stanislav Velikov
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

Posted by Community Admin on 17-Oct-2013 00:00

What's the best place to subscribe to this event, global.asax.cs, under Application_Start()?

For example:
Telerik.Sitefinity.Services.EventHub.Subscribe<Telerik.Sitefinity.Modules.GenericContent.Events.ICommentCreatingEvent>(evt => MySampleCommentNotificationMethod(evt));

???

Posted by Community Admin on 22-Oct-2013 00:00

Hello,

Yes this way the event subscription will be registered every time the application starts, here is a sample

protected void Application_Start(object sender, EventArgs e)
    Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
    EventHub.Subscribe<IDynamicContentUpdatedEvent>(evt => UpdatedEventHandler(evt));
      
    EventHub.Subscribe<IDynamicContentCreatedEvent>(evt => CreatedEventHandler(evt));
public void CreatedEventHandler(IDynamicContentCreatedEvent eventInfo)
    var userId = eventInfo.UserId;
    var creationDate = eventInfo.CreationDate;
    var dynamicContentItem = eventInfo.Item;
    var visible = eventInfo.Visible;
 
    //Your email logic upon item dynamic item creation.
public void UpdatedEventHandler(IDynamicContentUpdatedEvent eventInfo)
    var userId = eventInfo.UserId;
    var modificationDate = eventInfo.ModificationDate;
    var dynamicContentItem = eventInfo.Item;
    var visible = eventInfo.Visible;
 
    //Your email logic upon item dynamic item update.


Regards,
Stanislav Velikov
Telerik
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

Posted by Community Admin on 22-Oct-2013 00:00

Thanks for the reply. I think, however, I'm interested in seeing how this could be achieved with regular comment events, i.e., ICommentCreatingEvent.  We're unable to intercept/handle this event.

For example, we're trying to handle the ICommentCreatingEvent for comments that are created again blog posts in order to send an email notification.

Posted by Community Admin on 25-Oct-2013 00:00

Hello,

If you are using sitefintiy 6.1 I indicate a problem executing comment events, those are executed with success in sitefintiy 6.2.

Regards,
Stanislav Velikov
Telerik

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

This thread is closed