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

Forums / General Discussions / email notifications upon changes

email notifications upon changes

19 posts, 0 answered
  1. noam
    noam avatar
    5 posts
    Registered:
    18 Mar 2009
    20 Apr 2009
    Link to this post
    hi
    in the dashboard there is a panel showing the last modified pages.
    is there a way to get notifications (in push) when ever something changes on our website?

    Noam.
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    21 Apr 2009
    Link to this post
    Hi Noam,

    You can achieve that kind of customization. You need to subscribe to ContentManager.Executing event - it's being executed each time someone creates/updates/deletes content:

    Global.asax:
        void Application_Start(object sender, EventArgs e)  
        { 
            // Code that runs on application startup 
            Telerik.Cms.Engine.ContentManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(ContentManager_Executing); 
        } 
     
        void ContentManager_Executing(object sender, Telerik.ExecutingEventArgs e) 
        { 
            if (e.CommandName.Equals("UpdateContent")) 
            { 
                Telerik.Cms.Engine.IContent content = e.CommandArguments as Telerik.Cms.Engine.IContent; 
                if (content != null
                { 
                    string provider = content.ProviderName; //news, blogs, etc 
                    string text = content.Content; 
                    //send your e-mail. 
                } 
            } 
        } 

    Let me know if you need any further help.

    Regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Evgeny Vdovin
    Evgeny Vdovin avatar
    11 posts
    Registered:
    05 May 2006
    06 May 2009
    Link to this post
    Hi Georgi

    Very helpful topic you your solution work great. On questions.
    content.Content will return content text, but if this is news there should be content title, so my question is. How to get content title?

    Sincerely
    Evgeny Vdovin
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    07 May 2009
    Link to this post
    Hello Evgeny,

    Alright, if you want to take any metafield data like "Title", "Publication_date", "Author" and so on (defined in the web.config for the particular provider), you should use the following method:
    In short, if you want the Title then you:
    if (content != null)  
    {  
         string provider = content.ProviderName; //news, blogs, etc  
         string text = content.Content;  
         string title = content.GetMetaData("Title").ToString(); 
         //send your e-mail.  
    }  

    Let me know if you have any other questions ;)

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. sam
    sam avatar
    102 posts
    Registered:
    31 Jan 2008
    10 Jun 2009
    Link to this post
    Hi,

    What event captures when a comment is submitted for a blog entry?
    Because ContentManager_Executing is not fired..
  6. sam
    sam avatar
    102 posts
    Registered:
    31 Jan 2008
    10 Jun 2009
    Link to this post
    ok, ContentManager_Executing is fired when someone submits comments and the following code works:

    void

     

    ContentManager_Executing(object sender, Telerik.ExecutingEventArgs e)

     

    {


    if

     

    (e.CommandName == "CreateComment")

     

    {

    Telerik.Cms.Engine.Data.

    Comment comment = e.CommandArguments as Telerik.Cms.Engine.Data.Comment;

     

     

    if (comment != null)

     

    {

     

    string blogOwnerUserName = comment.Owner;

     

     

    string author = comment.Author;

     

     

    string authorEmail = comment.Email;

     

     

    string authorComment = comment.TextValue;

     

     

     

     

    foreach (Telerik.Cms.Engine.Data.Comment c in comment.Parent.Comments)

     

    {

     

    if (!string.IsNullOrEmpty(c.Email))

     

    {

     

    }

    }

  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Jun 2009
    Link to this post
    Hi sam,

    If you are working with content items you should also add "UpdateContent" as CommandName, because you will not be notified if the content is updated or not by someone.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. sam
    sam avatar
    102 posts
    Registered:
    31 Jan 2008
    10 Jun 2009
    Link to this post
    I don't understand what you are implying?


  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Jun 2009
    Link to this post
    Hello sam,

    It is better if you are adding UpodateContent as well to your code, not only when content item has been created.

     (e.CommandName == "CreateComment" && e.CommandName == "UpdateContent"


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  10. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    12 Jun 2009
    Link to this post
    Hey Sam, thanks for your contributions to this thread.

    I found this thread interesting and was experimenting with this today.  However, despite several tests I cannot seem to coax the ContentManager_Executing event into firing. 

    Here is the code I added to the ~/global.asax file:

        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) 
        { 
            Telerik.Utilities.Log.Trace("Test""This should write to the Sitefinity log file."); 
        } 

    As you can see, all I'm really trying to do is confirm the event is firing when I create, update or edit a Sitefinity page.  I'm doing this by writing a test message to the ~/App_Data/sitefinity.log file.

    This message never get written.  I've also put exceptions into the ContentManager_Executing method and these exceptions never get thrown.  From what I can see, this event is never fired.

    I'm using a fresh version of Sitefinity Blank Project 3.6 for my test.  Any idea what this event doesn't seem to fire? 

    It feels like I am probably missing something obvious.  :)

    Gabe Sumner
    http://www.sitefinitywatch.com/
  11. sam
    sam avatar
    102 posts
    Registered:
    31 Jan 2008
    12 Jun 2009
    Link to this post
    Thanks alot for your input Gabe.

    I created a break point within ContentManager_Executing method and it worked for me.
    But I was running the site via Cassini on my dev machine.
    That's where I was able to distinguish what was being updated or added from e.CommandName and e.CommandArgument
  12. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    12 Jun 2009
    Link to this post
    My answer was found in this thread:

    http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-bgcmtm.aspx

    I was using Telerik.Cms.Engine.ContentManager.Executing when I should've been using Telerik.Cms.CmsManager.Executing.

    One of these events is fired for Generic Content based resources and the other is fired for CMS pages.

    I knew it was something small like this.  I should've notices this earlier.  :)

    Gabe Sumner
    http://www.sitefinitywatch.com/
  13. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    13 Jun 2009
    Link to this post
    Ok, I stole everyone's work in this thread and turned it into a blog post:


    Here is the code I ended up with:

        public void Application_Start(object sender, EventArgs e) 
        { 
            Telerik.Cms.CmsManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(CmsManager_Executing); 
        } 
     
        public void CmsManager_Executing(object sender, Telerik.ExecutingEventArgs e) 
        { 
            // CHANGE THIS FOR YOUR SMTP SERVER !!!!! 
            string smtpServer = "smtp.yourisp.net"
             
            // Get information about the CMS page being modified. 
            var content = e.CommandArguments as Telerik.Cms.Data.CmsPageContent; 
             
            if (content != null
            { 
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); 
                message.From = new System.Net.Mail.MailAddress((Membership.GetUser("admin").Email)); 
     
                // Get all users in the Administrator role, Add each user to the email. 
                string[] users = Roles.GetUsersInRole("Administrators"); 
                foreach (string user in users) 
                { 
                    message.To.Add(new System.Net.Mail.MailAddress(Membership.GetUser(user).Email)); 
                } 
                 
                message.Subject = "Page: " + content.Title + " - Status: " + e.CommandName; 
     
                string body = 
                    "Title: " + content.Title + "\n" + 
                    "Version: " + content.Version + "\n" + 
                    "Date Created:" + content.DateCreated.ToString() + "\n" + 
                    "Date Modified:" + content.DateModified.ToString() + "\n" + 
                    "Description:" + content.CmsPage.Description + "\n" + 
                    "\nView this page:\n" + FixupUrl(content.DefaultUrl.Url) + "\n" + 
                    "\nEdit this page:\n" + FixupUrl("~/Sitefinity/admin/pages.aspx?select=" + content.ID) + "\n"
     
                message.Body = body; 
     
                // Send the email. 
                System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(smtpServer); 
                client.Send(message); 
            } 
        } 
     
        /// <summary> 
        /// This method accept a short URL (example: ~/page.aspx) and converts it to a full URL. 
        /// (example: http://www.fullwebsite.com:81/parent%20directory/page.aspx) 
        /// </summary> 
        public static string FixupUrl(string Url) 
        { 
            HttpRequest request = HttpContext.Current.Request; 
             
            string Port = request.ServerVariables["SERVER_PORT"]; 
            if (Port == null || Port == "80" || Port == "443"
                Port = ""
            else 
                Port = ":" + Port; 
     
            string Protocol = request.ServerVariables["SERVER_PORT_SECURE"]; 
            if (Protocol == null || Protocol == "0"
                Protocol = "http://"
            else 
                Protocol = "https://"
     
            string newUrl = Url; 
            if (newUrl.StartsWith("~")) 
                newUrl = (request.ApplicationPath + newUrl.Substring(1)).Replace("//""/"); 
             
            newUrl= Protocol + request.ServerVariables["SERVER_NAME"] + Port + newUrl; 
                             
            return newUrl.Replace(" ""%20"); 
        }     
     

    I add a bit of code to email all users belonging to the Administrators role, rather than hard-coding email addresses. 

    Hopefully this will prove slightly useful for someone else.

    For everyone who participated in this thread, thanks for your help!!!

    Gabe Sumner
    http://www.sitefinitywatch.com/
  14. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    16 Jun 2009
    Link to this post
    As Sam demonstrated above, the following code accesses the URL used by the blog post for which a comment is being made:

    Comment comment = e.CommandArguments as Telerik.Cms.Engine.Data.Comment;  
    comment.Parent.Url;  // <- Returns blog post URL 

    However, this returns URLs that look something like this:

    /09-06-12/Email_Notification_when_Sitefinity_Pages_are_Changed

    Notice ".aspx" is missing from the end of the URL.  Notice also that the prefix "/blog" (or whatever BlogPage your blog is using) is missing from the beginning of the URL.  This is how a blog post URL should look:

    /blog/09-06-12/Email_Notification_when_Sitefinity_Pages_are_Changed.aspx

    I could easily statically append these to the beginning and end of the URL, but it would be better to do this dynamically.  Sitefinity knows what BlogPage I've associated with my blog.  Sitefinity also knows the extension I'm applying to my pages. 

    Any ideas on how I dynamically create a full blog post URL?

    Gabe Sumner
    http://www.sitefinitywatch.com/
  15. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 Jun 2009
    Link to this post
    Hi Gabe Sumner,

    You can use content.UrlWithExtension to get the content url. For the application you can use content.ApplicationName. But, you cannot get the page. The easiest way is adding the page and building the link manually. Otherwise you should loop through all pages, find the control you are looking for( you should know its id) then get the page and use it in the link.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  16. Frank
    Frank avatar
    25 posts
    Registered:
    14 Jul 2008
    24 Jun 2009
    Link to this post
    Is there a way to get email notifications when a page is sent for approval or when a page is approved? I'd really like that instead of having to log in and check everyday.
  17. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    24 Jun 2009
    Link to this post
    Hello Frank,

    I have posted a reply to the ticket you have opened asking the same question. Please take a look at the other ticket.

    Greetings,
    Rado
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  18. citytech team1
    citytech team1 avatar
    16 posts
    Registered:
    17 Sep 2009
    30 Sep 2009
    Link to this post
    We have already completed a site in sitefinity. But only lacking some features that we need. In sitefinity currently it has subscription for newsletter. But we also need to implement Event and News subscription like Newsletter.
    We want to implement the features like-
    http://www.beeah-uae.com/en/contact
    In this page There are three checkbox for subscription to Newsletter, Events and News.
    It is also bi-lingual.
    Any code related to this will be very helpful.

  19. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Sep 2009
    Link to this post
    Hello citytech team1,

    Below is a sample code that covers desired functionality

    public class CustomSubscriptionForm : SubscriptionForm 
        public CustomSubscriptionForm() 
        { 
      
        } 
        protected override void CreateChildControls() 
        { 
            base.CreateChildControls(); 
             
        } 
        // IMLEMENT TEMPLATE HERE 
         
        protected override void OnSubscribe() 
        { 
            base.OnSubscribe(); 
            string subscriberEmail = string.Empty; 
            if (NewsCheckBox != null &&  NewsCheckBox.Checked) 
            { 
             // for instance set the Email and Names mode 
             this.formFieldsMode == FormFieldsMode.EmailAndNames  
             subscriberEmail = this.container.Sf2_email.Text.ToLower ( ).Trim ( ); 
             DataManager newsletterManager = new DataManager(); 
             ISubscriber subscriber = newsletterManager.GetSubscriber(subscriberEmail); 
             if(subscriber == null
             { 
                    subscriber = newsletterManager.CreateSubscriber (subscriberEmail); 
                    subscriber.FirstName = this.container.Sf_firstname.Text.ToString ( ).Trim ( ); 
                    subscriber.LastName = this.container.Sf_lastname.Text.ToString ( ).Trim ( ); 
                    // Create subsriber Group relation here 
                    // get subscriber by email 
                    ISubscriber subscriber = newsletterManager.GetSubscriber(subscriberEmail); 
                    // just for demonstration 
                    Guid groupID = new Guid("A15D355D-5547-4e4f-AEBD-E3E52BB76A93"); 
                    IGroupSubscriber groupSubscriber = newsletterManager.CreateGroupSubscriberRelation(groupID, subscriber.SubscriberId); 
                    newsletterManager.SaveSubscriber(subscriber); 
                    newsletterManager.SaveGroupSubscribers ( gSub ); 
             } 
            } 
            else 
            { 
                // checkbox is not checked 
                // do something else 
            } 
     
        } 
        public CheckBox NewsCheckBox 
        { 
            get 
            { 
                return base.container.GetControl<CheckBox>("news"falseas CheckBox; 
            } 
        } 
     

    1. You need to create a custom subscription control.
    2. Create a template for your control ( you can use SubscriptionFormTemplate.ascx).
    3. Create a reference to the controls inside this template.
    4. For the different subscription groups you can use switch case block.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
19 posts, 0 answered