Send Emails with Standard Paragraphs From Ninox

A couple of days ago, I wrote a post for users of Airtable and Knack about how to use Integromat to build a process to embed standard paragraphs into text and then send the result as an email to a Contact. In this post I'm going to repeat this topic for Ninox users - and you won't require Integromat to do it either.


Note that this post is quite similar to an earlier one dealing with sending bulk emails from Ninox based on templates (https://www.onlinedatabase.expert/post/sending-bulk-emails-in-ninox) - you could perhaps combine the two approaches...


First The database...


If you've read the previous post, you'll recall that we're going to need 3 tables for this:


Database Tables


You'll need the following fields in Contacts:


  • First Name

  • Last Name

  • Email Address




We then need a table to hold our Standard Paragraphs - and we'll need the following fields:


  • Name

  • Text (the text we want to insert)

  • Search for (the placeholder text we type into our email to be replaced - a formula such as "{" & Name & "}")




Finally, the Email to Contact table will need:


  • Message Entry (the text of this particular message)

  • Send To (Linked to the Contacts table)

  • And a button to send

  • Sent date/time



We'll create the send button later...


You'll notice that we won't be needing a separate field for the email sent or the time the record was updated to trigger the send. In this case we are going to use a 'Trigger After Update' to replace any placeholders in the test when the field is updated.


The Logic to Create the Text


The actual logic to replace standard paragraph placeholders with the long text is basically the same as in the Integromat based example:


  1. Loop through all Standard Paragraph records

  2. Use Replace function to search for place holders with the Search For text and replace with full text

  3. Search for any Contact Fields (First Name for example) and replace


Here's the code:


let newText := 'Message Entry';

for paragraph in select 'Standard Paragraphs' do

newText := replace(newText, paragraph.'Search For', paragraph.Text)

end;

newText := replace(newText, "{First Name}", Contact.'First Name');

newText := replace(newText, "{Last Name}", Contact.'Last Name');

'Message Entry' := newText


A little explanation - the for...in...do.........end structure reads and loops through all the records in the 'Standard Paragraphs' table and does whatever is between do and end. In this case, it uses the replace function to substitute text for the placeholders.


After all the standard paragraphs are replaced, two lines then replace any first or last names. Note that this means you could use {First Name} and {Last Name} field placeholders in Standard Paragraphs if you wish.


And here's an example of the field before updating:



and after moving to another field:




Sending the Email


As you can see it was pretty simple to get a few lines of code in Ninox to do the substitutions - one last step is to create the button to email this to your contact:




and the code fro the Send Email button is simply:


sendEmail({

from: "julian@kirkness.com",

to: Contact.Email,

subject: "Test Email",

text: 'Message Entry'

});

'Sent Date/Time':= now()


And here's the email:



As you can see, this is exactly the same as the message sent through Integromat - but the process of building this inside Ninox was, in my opinion, simpler.


Of course, in Ninox, it would then be simple to create a 'letter' version of this (especially if you added an Address field to Contacts:



And, modifying the button's code would enable this to be stored against the record = for example bu adding:


importFile(this, printAndSaveRecord(this, "Letter"), "Letter" + today() + ".pdf")


If you'd like to find out more about Ninox click here.

574 views1 comment

© 2019 by Kirkness Associate Ltd