Sending newsletters based on subscription preferences

In this tutorial, you'll learn how to configure JungleMail for Office 365 to send personalized newsletters based on subscriber's preferences. The following method is applicable only when sending to contacts stored in a SharePoint list. Subscribers and their preferences are added to the SharePoint list and updated through a form in a Power Apps portal page with the help of a Power Automate workflow. 


Configuration

This tutorial uses the following technologies: 

  • Power Apps portals, used to create a public website with pages containing for subscription and subscription management. 
  • Power Automate (former Microsoft Flow), used to create a workflow that adds or updates items in the SharePoint subscriber list when users subscribe or change their preferences.
  • SharePoint Online lists and libraries, used to store subscriber contact list and content related to subscription topics.
  • JungleMail for Office 365, used to create and send targeted newsletters that are automatically populated with content matching subscribers' preferred topics.

The configuration is divided into three main steps:

  1. Subscription page configuration. In this step, we'll create two pages in the portal: one to add the new subscribers, and another to update subscribers' information and preferences. Then, we'll create a Power Apps entity form and embed this form in the pages to collect and update subscriber data.
  2. Workflow configuration. In this step, we'll configure a Power Automate workflow which passes data from the entity form to the subscriber list in SharePoint and creates or updates items in the list.
  3. Newsletter template configuration. In this step, we'll set up a JungleMail for Office 365 newsletter template to automatically populate email body with content based on subscriber's preferred topics.

1. Subscription page configuration

Note

Before you can configure a subscription page, you need to create a Power Apps portal (website). To learn more about creating Power Apps portals, click here.

1. To begin with, you need to create an entity in the Power Apps portal that will store the data of your subscribers. Select the environment where the portal is provisioned. Then, select Data > Entities > New Entity.

2. Fill in the mandatory fields and click Create.

In the example, we've created the SubscriptionPreferences entity. To find it faster, we're using the Custom view.

3. Click on the entity, then click Add field to add fields that will be displayed in the subscription form. We recommend adding at least First Name, Last Name, Topics (Multiline Text data type) and Two Options data type fields for each of your subscription topics. This is required because, as of the time of writing this tutorial, Multi Select Option Set fields are available to add in the entity but are not displayed in the subscription form itself. To get the idea of how the Two Options fields look in the actual form, scroll down to the screenshot.

4. Select the Forms tab, then, hover over Main form type, and click Edit form.

5. From the Fields menu on the left, drag and drop the fields you've created into the form. On the Display options on the right, hide the Topics field label. Publish the form.

6. Create a new page in your portal. This page will be used to display the subscription form to users.

7. From the Components tab, add the form to the page. In the form settings, provide a name, and select the entity that you've created previously.

8. In the form settings window, set from mode to Insert. In this mode, whenever a form is submitted, it will create a new record in the Data tab of the entity.

9. Select the inserted form and at the bottom of the page, click </> to open the page code, then modify the code below based on the note and add it to your page.

<script> document.getElementById('cr59e_topics').style.display = 'none'; $(document).ready(function() { var $topics = $('#cr59e_topics'); $('#cr59e_subscribehealth_0').click(function() { var newVal = $topics.val().replace('Health;\n', ''); $topics.val(newVal); }); $('#cr59e_subscribehealth_1').click(function() { var actualVal = $topics.val().replace('Health;\n', ''); $topics.val(actualVal + "Health;\n"); }); $('#cr59e_subscribeit_0').click(function() { var newVal = $topics.val().replace('IT;\n', ''); $topics.val(newVal); }); $('#cr59e_subscribeit_1').click(function() { var actualVal = $topics.val().replace('IT;\n', ''); $topics.val(actualVal + "IT;\n"); }); $('#cr59e_subscribemarketing_0').click(function() { var newVal = $topics.val().replace('Marketing;\n', ''); $topics.val(newVal); }); $('#cr59e_subscribemarketing_1').click(function() { var actualVal = $topics.val().replace('Marketing;\n', ''); $topics.val(actualVal + "Marketing;\n"); }); }); </script>

Note

Field names used in the script must match those displayed in the entity Fields tab. Highlighted in yellow is the Topics field name. Highlighted in pink is the Health topic, and highlighted in red is the value that will be passed or removed from the Topics text field depending on subscriber's choices in the form.

Here's the finished subscription page with user data filled in:

10. In the same portal, create another page. This page will be displayed to subscribers who want to change their preferences. In the page, add a form of the same Entity, JavaScript code as before, but set Mode to Edit.


2. Workflow configuration

1. Log into Power Automate with your Office 365 account, and create a new workflow. This workflow will copy subscription form records to a SharePoint Online list. In the example below, we want to copy records to the External Subscribers list.

2. Add another workflow that will trigger if a subscriber changes his preferences. Note that in the example, the GUID column in the filter query has a slightly different internal name (GUID0). The same unique identifier should be used as in the previous workflow.

Here's how new entries look in the SharePoint list:


3. Newsletter template configuration

Now that you have subscription data in SharePoint, all that's left is configure a newsletter template to be automatically populated with content depending on subscribers' preferences. In the example, we're actually using three different SharePoint locations:

  • External Subscribers: the list where the workflow imports our subscription data.
  • Site Pages: the library where we post news as pages.
  • Topics: the list is used as an intermediary to match subscriber preferences with Site Pages content.
Note

The following tutorial skips the basic steps required to configure Dynamic Blocks and Dynamic Sections. For detailed instructions on how to configure targeted content retrieval, see Cascading Dynamic Content.

1. Open JungleMail for Office 365. In the Recipients step, select your recipient source. In the example, it's the External Subscribers list.

2. In the template, create a Dynamic Section, matching news topics (Topics list values) to the subscriber's preferred topics (External Recipients list values).

3. Create a Dynamic Block within the Dynamic Section, grouping news (Site Pages list values) by news topics (Topics list values). In the example, the News Type column contains subscription topic values.

4. Add the Text block with subscription management link. In the link options, select the HTTPS protocol, then enter the URL formatted as follows:

SubscriptionManagementPageURL?ID={[userID]}

In the example, userID is the display or internal name of the GUID column in the External Subscribers list. Put in brackets, this column value becomes dynamic, therefore the full URL will be unique for each subscriber.

5. Add the unsubscribe link.

Here's the template structure:

And here's the automatically populated content, as displayed in the Preview step. In the example, the recipient had subscribed to Marketing and IT topics.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.