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

Forums / Bugs & Issues / Forum: Email notification

Forum: Email notification

10 posts, 0 answered
  1. martin
    martin avatar
    36 posts
    Registered:
    30 Nov 2008
    06 Jul 2010
    Link to this post
    Hi,

    Is there anyway to send an email notification when a user adds a new post.
    I don't see any properties in the forum modules.

    Thanks
    Kieran
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    06 Jul 2010
    Link to this post
    Hi martin,

    Inside ~/Sitefinity/ControlTemplates/Forums/EditPost.ascx - you can get newly added content and all previous posts and send an emil to a user. Create a code behind of EditPost.ascx  template and on Page_Load subscribe for save button click.

    sample code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Data.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Forums.WebControls;
    using Telerik.Forums;
    using Telerik.Security;
    using System.Web.Security;
    using Telerik.Web.UI;
    using System.Net.Mail;
    using System.Collections;
    using Telerik.Forums.Data;
      
    public partial class Sitefinity_ControlTemplates_Forums_EditPost : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.saveButton.Click += new EventHandler(saveButton_Click);
        }
      
        void saveButton_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["mode"]) && !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["thread"]))
            {
                
                // send email to our subscriber that there is a new post
                foreach (var email in query)
                {
                    MailMessage message = new MailMessage("yourhost@here.com", email);
                    message.IsBodyHtml = true;
                    message.Body = "<b>ThreadConversation</b>:" + tbQuote.Content + "<b>LastReply is:</b>" + editor.Content + "<br />" + "<i>Click the link below to reply</i>" + "<p>" + uri;
                    message.From = new MailAddress("yourhost@here.com");
                    message.Sender = new MailAddress("yourhost@here.com");
                    SmtpClient client = new SmtpClient();
                    client.Send(message);
                }
              
            }
        }
    }


    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. martin
    martin avatar
    36 posts
    Registered:
    30 Nov 2008
    06 Jul 2010
    Link to this post
    Thanks
    Ivan

    One other quick Q.

    I want to have muliple forums across my site. Is there anyway of pointing to an external template so that I can have different layouts like you can do with other module eg News.

    Thanks
    Kieran
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    06 Jul 2010
    Link to this post
    Hi martin,

    It is possible if you create a custom provider that inherits from Telerik.Forums.ForumProvider. There are several properties that you can override and create switch statement.

    • SingleForumTemplate
    • ThreadedForumTemplate
    • ForumListTemplate
    • SingleThreadTemplate
    • EditPostTemplate
    • EditThreadTemplate


    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
  5. Pankaj
    Pankaj avatar
    39 posts
    Registered:
    27 Sep 2010
    10 Jan 2012
    Link to this post
    We have added forum controls on our website.
    we are looking code that can enable the notification when somebody replies to a post.
    version :3.7
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    11 Jan 2012
    Link to this post
    Hello,

    You can use the code from the previous post. You need to implement it in the proper templates that are mention in the last post made by me. The templates are part of the website.

    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
  7. Pankaj
    Pankaj avatar
    39 posts
    Registered:
    27 Sep 2010
    15 Jan 2012
    Link to this post
    Hi Ivan,

    Thanks for responding.
    But i am having a strange issue. As soon as i give reference of the code behind file in ascx.

    It shows nothing (blank) in edit post page when clicked on reply from threads.


    I added following on the top of ascx page
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="EditPost.ascx.cs" Inherits="Sitefinity_ControlTemplates_Forums_EditPost" %>

    I have following in cs file (i commented everything in the savebutton click event, just to limit the scope of the issue.

    using System;
    using System.Collections.Generic;

    using System.Data.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Forums.WebControls;
    using Telerik.Forums;
    using Telerik.Security;
    using System.Web.Security;
    using Telerik.Web.UI;
    using System.Net.Mail;
    using System.Collections;
    using Telerik.Forums.Data;
     
    public partial class Sitefinity_ControlTemplates_Forums_EditPost : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.saveButton.Click += new EventHandler(saveButton_Click);
        }
     
        void saveButton_Click(object sender, EventArgs e)
        {
    //i commented everything.
        }
    }


  8. Pankaj
    Pankaj avatar
    39 posts
    Registered:
    27 Sep 2010
    15 Jan 2012
    Link to this post
    works when i put that code in inline (in ascx).
    Thanks
  9. Pankaj
    Pankaj avatar
    39 posts
    Registered:
    27 Sep 2010
    15 Jan 2012
    Link to this post
    Getting Error at 'uri'.
    how can i fetch uri?
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    16 Jan 2012
    Link to this post
    Hi,

    Please elaborate some more about the issue with the url that you have now.

    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
10 posts, 0 answered