Smart repeat mailings with RRules

People are creatures of habit, offline and online. Simple examples are our weekly newsletter and monthly payments. Of course these are all automated, because why spend time on them if you don’t have to? Copernica’s software is able to capture such smart patterns through the use of RRules. RRules are sets of rules that can capture patterns as simple as “every week” to “every first monday in the months of April through August”. RRules can be used to schedule mailing and configure imports and exports. RRules are a component of the widely used iCalendar format, which allows for easy exchange of calendar information. In this blog we will teach you more about these useful tools.

One system to RRule them all

The RRule format is a powerful way to capture a repeating pattern. Like many powerful tools RRules can take a while to master. Luckily there are many tools available on the internet to help you compose them. An RRule consists of several components. As a company developing email marketing software we will, naturally, be discussing them in the context of mailings, but RRules can apply to many different entities. First of all there is a frequency, present in the RRule as ‘FREQ’. This indicates when the rule repeats, for example daily, weekly or monthly. The number of occurrences is indicated with ‘COUNT’ in the rule. The interval (‘INTERVAL’) is the number in front of the frequency. This can be two, for example, to indicate that a mailing should be sent every two weeks.

An example of an RRule is:

RRULE:FREQ=WEEKLY;COUNT=8;INTERVAL=2;

You can also read this as: “Every two weeks for 8 times”.

Besides these important components of the rule you can also indicate the day the week should start on (WKST) and the moment when it should be sent. The ‘BYWEEKDAY’ property for example indicates on which day of the week the mailing should be sent, ‘BYMONTH’ which day of the month, ‘BYYEARDAY’ the day of the year, etc. Another useful component is ‘BYSETPOS’ which indicates the position of a specific second, minute or hour. A combination of ‘BYSETPOS’ with a value of five and a ‘FREQ’ with value ‘MONTHLY’ for example will result in a mailing being sent only on the fifth day of the month.

A more difficult example of an RRule is:

RRULE:FREQ=WEEKLY;COUNT=8;INTERVAL=2;WKST=MO;BYDAY=WE;BYMONTH=4,5

Which you can read as “Every two weeks on wednesdays in April and May, for eight times.”

This format is a standardized format introduced by the Internet Engineering Task Force (IETF) in 1998. Internet protocols are documented in RFC documents, making it easier to exchange information of all types on the internet. RRules specifically were introduced as a component of iCalendar, which is meant to exchange calendar information. The iCalendar format was introduced in RFC 2445, but was revised in 2009. The most recent document about RRules and iCalendar is RFC 5545.

Starting with iCalendar

Maybe you were already wondering where the start- and enddates come in. These are not a part of the RRule itself, but rather of the iCalendar specification (as DTSTART and DTEND respectively). The iCalendar format also supports exceptions (EXDATE). This format can also contain information about who are invited to an event, who is present and much more. This powerful format is the standard on the internet for a reason and is used by big applications like Google Calendar, Apple Calendar and Microsoft Outlook. At the time of writing this format is not supported by Copernica yet, but you are now prepared for its possible introduction!