Reputation: 3095
A simple example of what I'm trying to accomplish using tag based code:
<cfmail
to="[email protected]"
from="[email protected]"
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( "[email protected]" );
mail.setFrom( "[email protected]" );
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?
Upvotes: 2
Views: 486
Reputation: 21
Not sure if this answers the initial question but fyi in coldfusion 10 I used to be able to tell CF to process other files than cfm. In your application use this line:
<cfset THIS.compileextforinclude = "htm" />
Upvotes: 2
Reputation: 15846
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.
Upvotes: 2