I have a legacy application where an email.cfm file is used with a cfmail tag to send e-mail:
<cfmail from="[email protected]" to="[email protected]" subject="New e-mail!">
// lots of HTML
</cfmail>
Now I'd like to update it for ColdFusion Model Glue 3. I want to send it using a mail object in the controller, and include in the body a CFM page:
var mail = new mail();
mail.setFrom("[email protected]");
mail.setTo("[email protected]");
mail.setSubject("New e-mail!");
mail.setBody( ** SOME CFM FILE ** );
mail.send();
Does anybody have any idea how I can do this?
I ended up following Henry's advice in the comments and created a CFML-based CFC:
Dave Long's suggestion is also good, which is to create components using
<cfcomponent>, then wrapping the code in<cfscript>tags. This gives you the ability to fall back to CFML in case the there is no cfscript equivalent or it's easier to do with CFML: