I have done exactly this (even under Cocoon CLI) but don't have the code to hand. It's quite straightforward except that the sendmail transformer invoked the pipeline to build the s/s which took so long that the sendmail connection was dropped. To solve this I ran one CLI to build the s/s and then scheduled the sendmail one an hour later.
I will dig out the code later. Regards
