Hey all, I'd like to use fckEditor to send out an HTML newsletter to a list I'm pulling from a coldfusion query. I've gotten the editor working (cfc), but I'm getting nothing when hitting the submit button. Basically, this is what I'm trying to work with:
<cfif mode IS NOT "submit">
<form name="sendmail" action="sendmail.cfm" method="post">
<cfscript>
fckEditor = createObject("component", "fckeditor/fckeditor");
fckEditor.instanceName="myEditor";
fckEditor.basePath="/www/webadmin/fckeditor/";
fckEditor.value="This is my <strong>initial</strong> html text.";
fckEditor.width="100%";
fckEditor.height="500";
// ... additional parameters ...
fckEditor.create(); // create instance now.
</cfscript>
<input type="hidden" name="mode" value="submit">
<input type="button" name="submit" value="submit">
<!--- <input type="button" class="button" value="submit" onClick="relocate('sendmail.cfm?mode=submit')"> --->
</form>
<cfelse>
<CFMAIL TO= ""
FROM= ""
SUBJECT= "NewsLetter">
#fckEditor.value#
</CFMAIL>
</cfif>
<cfif mode IS NOT "submit">
<form name="sendmail" action="sendmail.cfm" method="post">
<cfscript>
fckEditor = createObject("component", "fckeditor/fckeditor");
fckEditor.instanceName="myEditor";
fckEditor.basePath="/www/webadmin/fckeditor/";
fckEditor.value="This is my <strong>initial</strong> html text.";
fckEditor.width="100%";
fckEditor.height="500";
// ... additional parameters ...
fckEditor.create(); // create instance now.
</cfscript>
<input type="hidden" name="mode" value="submit">
<input type="button" name="submit" value="submit">
<!--- <input type="button" class="button" value="submit" onClick="relocate('sendmail.cfm?mode=submit')"> --->
</form>
<cfelse>
<CFMAIL TO= ""
FROM= ""
SUBJECT= "NewsLetter">
#fckEditor.value#
</CFMAIL>
</cfif>
RE: fckeditor as mail editor in coldfusion
The content from your example would be in form.myEditor, not fckEditor.value. And generally you want to scope your vars, to make things faster and cut down on errors. I.E. form.mode vs mode.
This should work(not tested):
<!--- begin code snip --->
<cfif isDefined('form.sendDaMail')>
<CFMAIL TO= ""
FROM= ""
SUBJECT= "NewsLetter">
#form.myEditor#
</CFMAIL>
<cfelse>
<form name="sendmail" action="sendmail.cfm" method="post">
<cfscript>
fckEditor = createObject("component", "fckeditor/fckeditor");
fckEditor.instanceName="myEditor";
fckEditor.basePath="/www/webadmin/fckeditor/";
fckEditor.value="This is my <strong>initial</strong> html text.";
fckEditor.width="100%";
fckEditor.height="500";
// ... additional parameters ...
fckEditor.create(); // create instance now.
</cfscript>
<input type="hidden" name="mode" value="submit">
<input type="button" name="sendDaMail" value="submit">
<!--- <input type="button" class="button" value="submit" onClick="relocate('sendmail.cfm?mode=submit')"> --->
</form>
</cfif>
<!--- end code snip --->
You also have to specify a from and to address in the cfmail (bet you knew that). And I hear structKeyExists(form,sendDaMail) is better than isDefined('form.sendDaMail').
That should get you going, hopefully.
###
I had a wonderful vacation, thanks for the well wishes, I'm sure they influenced my time. May y'all get some good vacationing sometime soon as well!!! Lord knows it ROCKS hee-yah! =-)
RE: fckeditor as mail editor in coldfusion
<cfif isDefined('form.sendmail')>
<cfquery name="getmaillist" datasource="#Application.dsn#">
SELECT *
FROM maillist
WHERE activeflag = 1;
</cfquery>
<cfoutput query="getmaillist">
<cfmail to= "#getmaillist.email#"
from= ""
subject= "NewsLetter">
#form.myEditor#
</cfmail>
</cfoutput>
<cfelse>
<form name="sendmail" action="sendmail.cfm" method="post">
<cfscript>
fckEditor = createObject("component", "fckeditor/fckeditor");
fckEditor.instanceName="myEditor";
fckEditor.basePath="/www/webadmin/fckeditor/";
fckEditor.value="This is my <strong>initial</strong> html text.";
fckEditor.width="100%";
fckEditor.height="500";
fckEditor.toolbarSet="Basic";
// ... additional parameters ...
fckEditor.create(); // create instance now.
</cfscript>
<input type="button" name="sendmail" value="submit">
</form>
</cfif>
RE: fckeditor as mail editor in coldfusion
Is there a history problem? Yay, verily, yay.
Didn't know basic toolbar fixed that... cool.
As for your form, I'm not sure of the problem. One for sure is that cfmail requires a "from" address. You should be getting err messages 'bout that tho.
One "trick" is to use some stuff that returns things to the display. Like after the cfmail, output the form.myEditor to the browser, so you see what, if anything, is getting passed.
A super useful thing is cfdump. I love it. I gently stroke it sometimes and coo at it how nice and dashing it be.
It's that good. =-)
You could put a <cfdump var="#form#"> right after the cfmail and see all form fields (names & values). You may want to do a <cfdump var="#getmaillist#"> to be sure you're getting records as well.
Also you generally want to avoid the "select * from" select statements. As you only need the email addy, just select that vs the whole record set. This will speed things up and make caching et al more kopasetic.
Looks like you're getting close!
Good luck and MTFBWY!
the pellet with the poison... no wait... the brew that's true...
--some old danny k flick
RE: fckeditor as mail editor in coldfusion