How to stop emails being automatically sent from your intervention (i.e. cancelling emails)
Cancelling e-mails that have been set up
There may be times when you need to cancel an e-mail that you may have set up. For example, if you have a number of sessions in your intervention and you wanted to send an e-mail to remind people if they do not log on to the next session, then you may set up an e-mail reminder to ask them to do so. However, if they do log onto the session before the reminder is sent out then you can set the logic up to cancel the email.
The logic for cancelling an e-mail includes the command cancelemail
followed by the unique e-mail name and the e-mail address. A basic written example of this logic would be:
cancelemail(unique name for e-mail, e-mail address)
The logic command will be written differently depending on where the e-mail address needs to be located (i.e. whether they use their e-mail address every time they log in to the intervention or if the e-mail address needs to come from the first time that they signed up to the intervention). Examples of the logic for these two possibilities are provided below.
Example 3: Cancelling an e-mail where the e-mail address is used to log-in to the intervention
A demo accompanying this example can be found on the LifeGuide Community site entitled Email Example 3. Note that for testing purposes the time for sending the e-mail has been set to 10 minutes (600 seconds).
show welcome
show signin
- Show end-users the first page of the intervention which has been given the unique name welcome. This page consists of a link to either a sign in page for new end-users to sign up for the intervention or a login page for registered end-users.
sendemail ("reminder1", signin.email, "Stress Less: Session 2", "This is your one week reminder for the Stress Less intervention", 352800)
- After the end-user has signed up to the intervention, a logic command is then set up to send an e-mail to them 1 week (or 352800 seconds) after they first visited this page to remind them to go back to the intervention for the next session. The unique name for this e-mail consists of the end-user’s username appended to the string reminder1. The e-mail address is taken from an interaction on the signup page that is uniquely named email.
- This logic would be written all on one line or can be broken up into two lines using …
show page1
show page2
show page3
- These pages represent the first session (of course one session is likely to be much longer than this).
show endsession1
- This is the last page of the session that encourages end-users to close the site and work on their goals for the week. Alternatively, users have a chance to skip straight to session 2 by clicking on a jump button that takes them to the sess2p1 page.
show login
show sess2p1
- If end-users select the login button on the welcome page they will go straight to the login page. Once logged in they will then go to sess2p1.
cancelemail ("reminder", login.email2)
show sess2p2
- If an end-user visits the sess2p1 page before the time specified on the sendemail command, then the e-mail will be automatically cancelled. This is the logic for cancelling the e-mail (again, this should be written on one line). The unique e-mail name is the same as the unique name in the sendemail command above and the e-mail address is taken from the interaction on the signin page.
- NB: This logic works on the notion that the person uses their e-mail address to log in to the session.
Example 4: Cancelling e-mails when the e-mail address needs to be taken from an earlier session of the intervention
show welcome
show signin
- Show end-users the first page of the intervention which has been given the unique name welcome. This page consists of a link to either a signin page for new users to sign up for the intervention or a login page for registered users.
after signin if (and (sendemail ("reminder1", signin.email, "Stress Less: Session 2", "This is your one week reminder for the Stress Less intervention", 600),...
savevalue (signin.uname, "email", signin.email) )) goto page1
- After the end-user has signed up to the intervention a logic command is then set up to send an e-mail to them 1 week (or 352800 seconds) after they first visited this page to remind them to go back to the intervention for the next session. The unique name for this e-mail consists of the end-user’s username appended to the string reminder1. The e-mail address is taken from an interaction on the signup page that is uniquely named email.
- Here the savevalue command is used to save the e-mail address of the end-user against their username so that the e-mail address can be loaded in subsequent places in the logic.
show page1
show page2
show page3
- These pages represent the first session (of course one session is likely to be much longer than this).
show endsession1
- This is the last page of the session that encourages end-users to close the site and work on their goals for the week. Alternatively, users have a chance to skip straight to session 2 by clicking on a jump button that takes them to the sess2p1 page.
show login
show sess2p1
- If end-users select the login button on the welcome page they will go straight to the login page. Once logged in they will then go to sess2p1.
cancelemail ("reminder", loadvalue (signin.uname, "email"))
show sess2p2
- If an end-user visits the sess2p1 page before the time specified on the sendemail command then the e-mail will be automatically cancelled. This is the logic for cancelling the e-mail (again, this should be written on one line). The unique e-mail name is the same as the unique name in the sendemail command above, and the e-mail address is loaded from the information that has been saved as email which was taken from the interaction on the signin page.