How to automatically send an email from your intervention on a certain date
When you want the e-mail to be sent out
The final part of the logic command refers to when you want the e-mail to be sent out. This number needs to be in seconds and relates to how long after the end-user has viewed the page mentioned before it that it should be sent. So if you want the e-mail to be sent after 24 hours this will be 86400 seconds.
Because of this time element, you can have a number of e-mails stored up after the end-user has visited the page. This is especially useful if you want to send out automated reminders to users throughout the course of using the intervention.
N.B. Our server send out emails every 5 minutes. If your emails are to be sent out for example, 30 seconds apart, you may receive all the emails at the same time.
The rest of this chapter provides two examples of logic for sending out automated e-mails; the first involves sending e-mails out to end-users and the second for sending e-mails out to a researcher (or other fixed person).
E-mail times at a glance
The following list provides a set of times and their corresponding number of seconds. For testing purposes, reduce the numbers to a shorter, more convenient time.
1 minute - 60
30 minutes - 1800
1 hour - 3600
12 hours - 43200
1 day - 86400
2 days - 172800
3 days - 259200
4 days - 345600
5 days - 432000
6 days - 518400
1 week - 604800
2 weeks - 1209600
3 weeks - 1814400
4 weeks - 2419200
5 weeks - 3024000
6 weeks - 3628800
7 weeks - 4233600
8 weeks - 4838400
9 weeks - 5443200
10 weeks - 6048000
15 weeks - 9072000
20 weeks - 12096000
25 weeks - 15120000
30 weeks - 18144000
35 weeks - 21168000
40 weeks - 24192000
45 weeks - 27216000
1 year - 31536000
Sending emails on a specific date
To send an email on a specific date, you will need to find the computer representation of that date. Computers represent time as the number of seconds elapsed since 1st January 1970 00:00:00 GMT, so for example, if you want to send an email at 1.00pm on 1st June 2012, you would have to first calculate how many seconds there are between 12.00am on 1st January 1970 and 1.00pm on 1st June 2012. You can use the following website to help you do this:
http://www.onlineconversion.com/unix_time.htm
Simply type the date and time you want the email to be sent into the boxes under the main heading: Convert a Date/Time to a Unix timestamp
Important: this is an American website, so you will need to enter the date in MM/DD/YYYY format rather than DD/MM/YYYY format.
Then subtract the current time (using the function currenttime
) from the number you get from the website. The logic will look like this:
sendemail
(unique name for e-mail, e-mail address, "Subject message for e-mail", "E-mail content"
, the number in seconds of the date you want the email to be sent – currenttime())
Example
If you want to send an email to end-users at 9:00am on 7th January 2011, type the date and time into the above website. This date and time is equal to 1294390800 seconds.
The logic to send an email at 9.00am on 7th January 20100 would be written like this:
sendemail(“welcomeemail”, username, "Session 2", "Please log in to the website and complete Session 2.", 1294390800 – currenttime())