When I try to do the above, I get the error "Warning at framework/view/SSViewer.php line 780: None of these templates can be found in theme 'mytheme'" and the template fails to be loaded.
It seems that when I use:
It is looking somewhere else for the template and not finding it. I have 5 other cases where emails are being sent successfully, and in all other cases, the code is in a controller rather than a dataobject.
I'm fairly new to SilverStripe, so perhaps I'm putting the code in the wrong place. The underlying requirement is that I need to override the onBeforeWrite function for a dataobject so that it sends an email in some circumstances. Perhaps the email sending could be done from something other than my dataobject?
The permissions of the template in question are the same as all the other templates that work, and I have done a ?flush=all and deleted the silverstripe files from /tmp/...