Forums

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Bugs & Issues > Forum: Email notification

Forum: Email notification

  • martin avatar

    Posted on Jul 6, 2010 (permalink)

    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

    Reply

  • Ivan Dimitrov Ivan Dimitrov admin's avatar

    Posted on Jul 6, 2010 (permalink)

    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

    Reply

  • martin avatar

    Posted on Jul 6, 2010 (permalink)

    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

    Reply

  • Ivan Dimitrov Ivan Dimitrov admin's avatar

    Posted on Jul 6, 2010 (permalink)

    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

    Reply

  • Pankaj avatar

    Posted on Jan 10, 2012 (permalink)

    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

    Reply

  • Ivan Dimitrov Ivan Dimitrov admin's avatar

    Posted on Jan 11, 2012 (permalink)

    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

    Reply

  • Pankaj avatar

    Posted on Jan 15, 2012 (permalink)

    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.
        }
    }


    Reply

  • Pankaj avatar

    Posted on Jan 15, 2012 (permalink)

    works when i put that code in inline (in ascx).
    Thanks

    Reply

  • Pankaj avatar

    Posted on Jan 15, 2012 (permalink)

    Getting Error at 'uri'.
    how can i fetch uri?

    Reply

  • Ivan Dimitrov Ivan Dimitrov admin's avatar

    Posted on Jan 16, 2012 (permalink)

    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

    Reply

  • Register for webinar
Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Bugs & Issues > Forum: Email notification