A simple example of what I'm trying to accomplish using tag based code:
<cfmail
to="someone@x.com"
from="someone@y.com"
subject="howdy"
type="html">
<cfinclude template="path/to/emailtemplates/sometemplate.htm"/>
</cfmail>
I've tried all manner of solutions using cfscript and am at a roadblock. I thought this might do it, but alas no.
savecontent variable="mailBody" {
include "path/to/emailtemplates/sometemplate.htm";
};
mail = new mail();
mail.setTo( "someone@x.com" );
mail.setFrom( "someone@y.com" );
mail.setSubject( "howdy!" );
mail.setType( "HTML" );
mail.setBody( mailBody );
mail.send();
We're not sending multi-part e-mails - just HTML. Is there a way to do this in script?
The issue is that, in cfinlcude
you will not be able to include an HTML
file. Looks like you are going to need the help of FileRead()
function instead of include.
mailBody=FileRead('absolute/path/to/emailtemplates/sometemplate.htm' [, charsetIfNeeded]);
For FileRead
to work you should provide an absolute path to an on-disk or in-memory text file on the server.