<!---
This example uses a table called EmailTemplates with the following columns
`ID` INT(11)
`sender` VARCHAR(255)
`subject` VARCHAR(255)
`htmlbody` BLOB //The html pages are stored in this column
`textbody` BLOB //The text pages are stored in this column
--->
<!--- Set defaults --->
<cfparam name="mailto"
default="[Email Address]">
<cfparam name="mailID"
default="59">
<cfparam name="path_to_file"
default="C:\path_to_file\">
<cfparam name="DSN"
default="MYDSN">
<!--- Create a random filename for the html doc--->
<cfset html_file = #RandRange(1000,100000)#&'.cfm'>
<!--- Create a random
filename for the text doc--->
<cfset text_file = #RandRange(1000,100000)#&'.cfm'>
<!--- Query the
database for the proper email to send, choose your own criteria --->
<cfquery datasource="#MYDSN#"
name="getliterature">
SELECT * FROM EmailTemplates WHERE ID = #mailID#
</cfquery>
<!--- Write the
temporary file with the HTML contents of the email body --->
<cffile action="write"
nameconflict="makeunique"
file="#path_to_file##Variables.html_file#"
output="#getliterature.htmlbody#">
<!--- Write the
temporary file with the TEXT contents of the email body --->
<cffile action="write"
nameconflict="makeunique"
file="#path_to_file##Variables.text_file#"
output="#getliterature.textbody#">
<!--- Save the
variable with the contents of the saved HTML file --->
<cfsavecontent variable="HTMLBody">
<cfoutput>
<cfinclude template="#Variables.html_file#">
</cfoutput>
</cfsavecontent>
<!--- Save the
variable with the contents of the saved TEXT file --->
<cfsavecontent variable="TextBody">
<cfoutput>
<cfinclude template="#Variables.text_file#">
</cfoutput>
</cfsavecontent>
<!--- Send the mail
message--->
<cfmail to="#mailto#"
from="#getliterature.sender#"
subject="#getliterature.subject#"
type="html">
<cfmailpart type="html">
#HTMLBody#
</cfmailpart>
<cfmailpart type="text">
#TextBody#
</cfmailpart>
</cfmail>
<!--- Delete the temporary file created earlier --->
<cffile action="delete"
file="#path_to_file##Variables.html_file#">
<cffile action="delete"
file="#path_to_file##Variables.text_file#">
Date added: Tue. March 30, 2004
Posted by: Derrick Anderson | Views: 8129 | Tested Platforms: CFMX | Difficulty: Intermediate
Best Practices
Boost your applications performance with cached CFCs
When using the cfinvoke tag or the CreateObject function on your pages, it adds CPU time to process the requests to load all of those objects into memory. Under load this can make quite a difference in your page response times. One way to get around it is to put those objects into a shared scope so they only get instantiated once. This will save memory and CPU time on your server. - Date added: Thu. August 31, 2006
|
BS
Nice to see things that I wrote are on the web now under somebody elses name with cfmail added to it ;)
Posted by: Annon
Posted on: 10/29/2005 06:29 AM
|
don't think so pal
If you are suggesting that i copied this from you, you are mistaken.
CF Code is not very complex, many people have written code just like the code tutorials here on easycfm, you should not assume you've been copied when you see similar code to what you may have written in the past, i see it all the time.
Posted by: DA
Posted on: 11/01/2005 08:02 AM
|
Thanks a bunch!
Thanks man, this is just what I needed. Not all of it, but a decent chunk I won't have to reinvent!
Posted by: PJ
Posted on: 08/18/2006 05:45 AM
|
|