Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Swathi 87 posts 281 karma points
    Sep 03, 2015 @ 12:36
    Swathi
    0

    Can we subscribe and receive Emails on addition of any new content in backoffice?

    Hi,

    So I want my users to be able to subscribe to my website. Is it possible to send them a mail when any new page is added in the content section of backoffice? (name and url of new page)

    Swati

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Sep 03, 2015 @ 14:01
    Warren Buckley
    101

    Hello Swathi,
    Yes this could be done with an Umbraco ContentService event.

    So whenever a content node is published you are able to be notified of what node & url of that page was published.

    https://our.umbraco.org/documentation/Reference/Events/

    https://our.umbraco.org/documentation/Reference/Events/Application-Startup

    https://our.umbraco.org/documentation/Reference/Events/ContentService-Events

    You could pass this to some function/method that would send out the newly published page to say a MailChimp subscriber list.

  • Swathi 87 posts 281 karma points
    Sep 07, 2015 @ 06:13
    Swathi
    0

    Hi Warren,

    Im sorry this is not clear, can you please give more details? How do i make this work

    Swati

  • jigar 170 posts 233 karma points
    Sep 07, 2015 @ 06:46
    jigar
    0

    Hi Swathi,

    Warren Buckley has explained nicely!!!

    You need to override the Published event of ContentService.

    First you need to add a class file in your umbraco project, using visual studio (obviously) and then put the following code in you class file.

    using Umbraco.Core;
    using Umbraco.Core.Events;
    using Umbraco.Core.Models;
    using Umbraco.Core.Publishing;
    using Umbraco.Core.Services;
    
    namespace My.Namespace
    {
        public class MyEventHandler : ApplicationEventHandler
        {
    
            protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
                ContentService.Published += ContentServicePublished;     
            }            
    
            private void ContentServicePublished(IPublishingStrategy sender, PublishEventArgs<IContent> args)
            {
                foreach (var node in args.PublishedEntities)
                {
                    if (node.ContentType.Alias == "YourDesireDocumentType")
                    {
                        SendMail(node);
                    }
                }
            }
        }
    }
    

    Here the SendMail module can be replace with sub routine like, sendemailusingmailchimp().

    Hope this helps.

    LUV Umbraco.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies