In this recipe we create a rule configuration that sends a reminder e-mail to a user that hasn't logged in to the website for a week.
Create a new Action set component and provide a user object as a parameter.
Add a new Action, System | Send mail and configure the various fields, set the To field to [user:mail], enter a subject and fill in the MESSAGE field with something such as
Hey, you haven't logged in to our site for a week now....
Add a new rule configuration and set the Event to User | User has logged in.
Add an Action, Rules scheduler | Schedule component evaluation.
Select the component which we created in step 1.
Click on Switch to direct input mode and enter +7 days.
Set a unique identifier to this scheduled component.
Provide the account object to the component.
In this example we wanted to send reminder e-mails to individual users, who haven't logged in to the website for a week. For that we've created a component (that executes the Send mail Action), which we use in our rule configuration as a scheduled component. In the rule configuration, we set the Event to User has logged in because we want to set the scheduled date to a week from the user's last login. Please note that you'll need cron running for the scheduler to work.
Additionally, we would probably want to add an Action Delete scheduled tasks, using the same identifier we've used for the scheduled component and place it before the Schedule component evaluation Action.
This way we make sure that the scheduled date always gets updated when the user logs in and new reminders get scheduled.
Rules Scheduler provides a user interface through the
Views module which can be found at Configuration | Workflow | Rules | Schedule. This interface can be very useful as it displays all the components that are scheduled for execution. It is also a very useful tool for debugging scheduled components.