E-mail notifications

Sean Zarb Ferrante asked on July 24, 2018 14:44

Hi, I'm not very familiar with Kentico out of the box features. and would be appreciated if you can suggest the best practice for me to implement the below.

I have a News module which is bound to a category.

Users need to register and choose the Categories which s/he would like to get the notification, and also frequency of the email, (Daily, weekly or monthly).

Recent Answers


Trevor Fayas answered on July 24, 2018 15:18

While Kentico has OOB single Newsletter Subscribe webparts, and a "My Account" Web part that allows users to be removed from subscriptions they already have, what you are describing may need to be done custom, unless i'm mistaken.

Within the Kentico structure, there is a CMS.Newsletters.SubscriberInfo and a CMS.Newsletters.SubscriberNewsletterInfo object.

The subscriber is the person, and there is a "CustomData" field on the SubscriberInfo that you can SetValue("Name", object) and GetValue("Name") on. This is where you would store the additional information for that subscriber, such as a dictionary of the subscription newsletters along with the frequency they wish to get those subscriptions. You'll need to code a custom webpart that will list your newsletters with a frequency, and then either update the existing subscriber or create a new one and add in this info.

Next you would actually subscribe them to the newsletters they are subscribed to (CMS.Newsletters.SubscriberNewsletterInfoProvider.AddSubscriberToNewsletter(subscriberId, newsletterId, when))

Lastly you'll need to add an event hook (CMS.Newsletters.NewsletterEvents.GenerateQueueItems.Before) to check if the particular newsletter should be sent out to the user (maybe also add a "DateLastReceivedNewsletter" dictionary to the subscriber so you can see if the date between now and the last received newsletter is greater than their frequency?)

Hope that helps!

0 votesVote for this answer Mark as a Correct answer

Suneel Jhangiani answered on July 24, 2018 20:10

Whilst Trevor has already provided an answer I think you would be best to implement this using a Custom Scheduled Task. It's going to sound a bit strange, I recommend looking at https://devnet.kentico.com/articles/adding-custom-workflow-notifications-to-kentico

The scheduled task can run daily at a predetermined time and use custom fields / data from the UserInfo or UserSettingsInfo classes to hold which categories they are subscribed to, the frequency of the emails and when the last email was sent.

You could also look at setting content notifications although you would have to consider how to handle the daily, weekly or monthly. One trick is to have a News listing page and trigger an Update on that page when a new news item is added, which in turn can trigger a content change notification for which you implement custom code that pulls a list of subscribed users and checks when they were last sent an email, but it would require regular new items to be added.

0 votesVote for this answer Mark as a Correct answer

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