I want to create a Subscription page that allows the website visitors to subscribe for new page is c

Surendar Boopalan asked on October 23, 2017 23:07

In our website we have a page to post New meeting Agendas. I want to create a Subscription page that allows the website visitors to subscrible for the new meeting agendas. The page should collect email addresses, store and should send emails to the users who are subscribed to receive new agendas.

The new meeting agendas page has a custom table. Please advise how to create a subscription module for new website pages.

Recent Answers


Matt Nield answered on October 24, 2017 01:20

hi Surendar, if I undestand correctly, you're storing your agendas in the custom table. If that is the case, then I would use a global object event to sent your emails.

To capture the subscriber emails, you can create a simple form in the Forms application. This form would probably only need to contain the users name and email. When the user submits the form, their details will be stored in teh database. You can also setup Kentico to send a qucik email to them at this point using the Autoresponder to let them know what they've signed up to.

To send the emails when new agendas are create, you could create a new class in App_Code (or Old_App_Code if you're running a website project rather than a web application project) that looks similar to the following:

using CMS;
using CMS.DataEngine;
using CMS.EmailEngine;

[assembly: RegisterModule(typeof(CustomTableEventHandler))]
public class CustomTableEventHandler : Module
{
    public CustomTableEventHandler() : base("CustomTableEventHandler") { }
    protected override void OnInit()
    {
        // Assigns custom handlers to events
        ObjectEvents.Insert.After += Insert_After;
    }

    private void Insert_After(object sender, ObjectEventArgs e)
    {
        switch (e.Object.TypeInfo.ObjectType)
        {
            case "customtableitem.customtable.sampletable":
                // Send your emails here...
                var email = new EmailMessage();
                email.Recipients = "to@foo.com";
                email.From = "no-reply@foo.com";
                email.Subject = "New meetings agenda";
                email.PlainTextBody = "Some nice message";
                EmailSender.SendEmail(email);
                break;
            default:
                break;
        }
    }
}

What next? Well, where the block is that you're sending emails, you can use database queries in the API to pull your list of subscribers from the Form created in order to gather the recispients for the email. To make the emails more manageable, you can then use email templates to format your content.

4 votesVote for this answer Mark as a Correct answer

Matt Nield answered on October 25, 2017 10:35

Hi Surendar, did the above help at all with your requirement? Happy to provide further reponses if there is more you need. :)

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.