Poco Script FAQ - Scheduling EMail

Poco Script FAQ - Scheduling EMail

Q: Is there a script or function in Poco that you can use to schedule outgoing emails? For example have one email go out every month, another every hour, or whatever?

Someone I know wants to do this to email her pager with reminders, etc. Dunno if that will be workable, but it seems like a good idea.

 
A: This would be difficult but not impossible to achieve with Poco. You'd have to have a means of programming a scheduler of some sort. That scheduler would launch a process that would interrogate a file to determine which Poco action was to be performed and build a script to perform that process. The process would then launch Poco with the "/r" command line parameter to run the script as it starts. You would also probably want to use the "/q" parameter to quit poco once the operation was finished.

This is by no means a trivial task and much of it would be done outside of Poco itself. (Hint: You may be able to use NoteTab to achieve some of this, it supports timer events and you could launch a clip to create a script and then launch Poco itself).


Actually, I think it's a bit easier than doing something outside of Poco. Granted, it won't run independently (sorta, see below), but if you read your mail on a regular basis and remember to hit the "process scheduled messages" button that you assign, then it could be done.

As with other script concepts, these are ideas not solutions. Someone else can write the solution if they care to. Essentially you'll need two scripts. The first one gets run on selected messages QUEUED to be sent (that is, you write your message normally, and 'queue' it; then you go to the outbox and run this script against the message(s) to be queued). You'll input for a date value and the script will move the message to a Scheduled mailbox that you specify (it will create it if it does not exist; standard Poco capability). The date value would be stored in a header, say, X-Poco-scheduled-for.

The second script will be run periodically on the Scheduled mailbox. Until some mailbox/message looping commands are added to PocoScript (this is being discussed), you'll have to select the messages for processing, but that will change in the long term. The script itself would check to see if the current message has an X-Poco-scheduled-for of the current date or earlier. If so, then the message is moved back to the outbox -- but remember to deleted the X-Poco-scheduled-for from the message unless you want your recipients to be able to see that.


Followup on the above method:

There are a few restrictions with the above method, the major one being that you must not have the "Send queued messages when sending mail" option checked ("Sending mail" tab of the "Program Options" window).

You will also have to be careful when you press the button to send the queued messages, if any are in the "Out" mailbox that you want to be delayed but have not run the first script no them they will be sent! (It might be better to save them to the "Drafts" folder rather than the "Out" box, this would remove both the restrictions I have mentioned here).