View Full Version : Flash Email Form and Coldfusion
majinpunisher
07-22-2004, 10:12 PM
Hey everyone, I've been pulling my hair out over this problem.
I'm working on a simple contact form from a flash site to send with Coldfusion (we don't have php or asp or anything on the server).
Here's my basic form:
three input text fields. Name, Email, and Message.
here's the actionscript on my submit button:
on(release){
loadVariablesNum("http://hobbes/ditflash/cfmail.cfm",0,"POST");
_root.gotoAndPlay("thankyou");
}
*Note: The few times it worked, I had to reference the specific url even though the .swf file is in the same directory. Go figure.
My cfml:
<cfmail to="myaddress@myurl.com" from="#email#" subject="Message from DIT Flash Site Contact Form">
The following is a message from the DIT Flash site email form.
From:
#name#
Email Address:
#email#
Message:
#message#
-End Message-
</cfmail>
Here's the few problems I've had:
I got the form to work and send email successfully. However, if I hit return in my message then all the text after the carriage return is not sent in the email.
I changed the "message" input text field to "Render text as html" but that made it stop working, and upon changing it back, it still hasn't worked.
Also, finally, even when it worked, there were several messages that were just dropped, even though my coldfusion sentmail log logged them as sent.
All of your expertise and help is greatly appreciated. I'm still extremely amateur with coldfusion and action scripting.
-Andy W.
if your coldfusion log is logging the mails as sent, then you don't have a problem between flash and cf, but you might have a problem between cf and your email server.
what version of cf are you using?
what version of flash are you using?
majinpunisher
07-23-2004, 04:52 PM
I'm using Flash MX. I can't remember what version of ColdFusion the office is running, I'll have to wait till I can get back in on Monday to find out specifically. But I know the ColdFusion version is whichever version was the latest version this time LAST year.
Also, like I said, *some of the emails that were logged as being sent were lost, not all of them.
Also again, after I tried something, it stopped working all together, even when after I changed the files back to their "working" condition.
Thanks for helping me look into this.
-Andy
i just looked at an old email app i did in cf a while back. you will need to actually parse the input text, and insert \n
here is the actual code i used to build the message body:
buildMessageBody=function(){
var mb=new String();
mb="Monthly report for team: "+team_cb.getSelectedItem().label+"\n\n";
mb+="Date submitted: "+new Date()+"\n\n";
for(var i=0;i<nbrQs;i++){
n=i+1;
mb+=tl["q"+n].text+"\n";
mb+=tl["a"+n].text+"\n\n";
}
trace(mb);
return mb;
};
your using either cfmx (or cfmx2004?? does that exist)? anyway, here is my cf4.5 code for sending the email:
<!--- tell cf not to suppress white space --->
<cfprocessingdirective suppresswhitespace="no">
<cftry>
<!--- message variables --->
<cfset mailTo=#FORM.mailTo#>
<cfset mailccTo=#FORM.mailccTo#>
<cfset mailFrom=#FORM.mailFrom#>
<cfset mailSubject="STP Monthly Report - Team " & #FORM.team#>
<cfset mailBody=#FORM.mailBody#>
<!--- server variables --->
<cfset mailServer="mymailserver">
<cfset mailPort="25">
<cfset mailTimeout="5">
<cfmail
to=#mailTo#
from=#mailFrom#
subject=#mailSubject#
cc=#mailccTo#
bcc=#mailFrom#
server=#mailServer#
port=#mailPort#
timeout=#mailTimeout#>
<!--- body --->
#mailBody#
</cfmail>
<cfoutput>&error=false&</cfoutput>
<cfcatch>
<cfoutput>&error=true&</cfoutput>
</cfcatch>
</cftry>
</cfprocessingdirective>
<cfinclude template="insertEmail.cfm">
majinpunisher
07-23-2004, 10:33 PM
I'm able to follow what you're doing with your cfml, but I'm not advanced enough to understand your action script. I know its annoying for me to ask, but could you be a little more expository with your actionscript to tell me what's going on? Like what your input text variables are, etc.
/n is to help fix my carriage return problem, right?
Also, do I need to establish my variables in my cfml as "FORM.variable"?
Sorry for my amateur-ness.
-Andy
andy,
i'm home now, won't be back intothe office until monday. i'll have to get back to you then.
majinpunisher
07-26-2004, 04:25 PM
I'm back at it again.
I've established that its not the cfml that's the problem, because I went in and hardcoded the variables in it, and ran it manually with getURL in flash, and successfully sent the dummy email.
So I guess my problem is in trying to get the data passed to coldfusion properly, and making sure that I'm referencing the coldfusion file appropriately. Then there's the problem of the carriage return ending the string. I definitely need help on that parsing data solution you gave me.
I've searched these forums over and over again, and the only carriage return problems I've run across are flash reading carriage returns as two carriage returns, in the instance of "\r\n". Nothing on flash killing the rest of the text after thefirst carriage return.
Likewise, I've found that the majority of information on this stuff on these forums and others is for pulling data into flash, and not so much on passing it out.
I also don't fully understand the difference of layers versus targets in loadVariablesNum versus loadVariables. I'm not even sure I understand the layers thing fully yet.....
The last thing I should ask is, I've got my three text fields (name, email, and message) combined in a Graphic, not in a movie clip. Should I bring them all together in a movie clip instead?
Many thanks for putting up with my annoying beginner questions.
-Andy
majinpunisher
07-26-2004, 08:56 PM
OK, now I'm getting somewhere:
Got it to do "something" again. My CFML is basically the same, as is the actionscript, basically:
on (release) {
loadVariablesNum("http://richmond.k12.va.us/ditflash/ditflashmail2.cfm, _root, "POST");
_root.gotoAndPlay("thankyou");
}
My two issues are: 1.)Still have the carriage return problem. I understand TG, that you and all you other amazing Flash/ColdFusion gods are busy people, but if you could elaborate on how you believe I need to solve my carriage return problem from my multiline text field, that would be great. I refer to it as the variable "message".
2.)The way my actionscript on my submit button works now, it opens a blank new window of my ditflashmail2.cfm file, I'm going to test it out, but do you suppose its because I'm referring to the location as "_root" instead of "0"?
-Andy
majinpunisher
07-27-2004, 03:16 PM
Blank window popup issue has been resolved.
TG, your code is to physically insert your "\n" in the places where you want it. That's not exactly what my issue is.
Upon clicking "send", the email is successfully sent, however, in the message field, all data is lost after the first carriage return.
We've got some code that was an attempt at finding the flash carriage return and replacing it with something that would make it to the cfml. It didn't work.
My three text fields are still "name", "email", and "message".
The code we used was:
on(release){
var smessage = new String();
smessage = message.text;
var counter = 0;
var find = "\n";
var replace = "<BR>";
while (counter<smessage.lenth){
var start = smessage.indexOf(find, counter);
if (start == -1){
break;
} else {
var before = smessage.substr(0, start);
var after = smessage.substr(start+find.lenth, smessage.lenth);
smessage = before+replace+after;
var counter = before.lenth+replace.lenth;
}
}
loadVariablesNum("http://richmond.k12.va.us/ditflash/ditflashmail3.cfm", 0, "POST");
_root.gotoAndPlay("thankyou");
}
*the cfml(ditflashmail3.cfm):
<cfmail to="me@myurl.com" from="#email#" subject="Message from DIT Flash Site Contact Form">
The following is a message from the DIT Flash site email form.
From:
#name#
Email Address:
#email#
Message:
#smessage#
</cfmail>
The email sends, but nothing shows up at all now for "smessage".
Again, I greatly appreciate anyone that can help me.
-Andy
majinpunisher
07-29-2004, 09:07 PM
Just updating my progress again, if any of you brilliant ladies and gents care to help. I've worked it out so that my cfml send the message, the message sends, but:
No matter what function I've tried, all text is lost after the first carriage return the user enters into the message field. I even just tried this code, from the email and php tutorial:
on(release){
message_send = message;
while (msg_count<length(message)) {
msg_count = msg_count+1;
if ((substring(message_send, msg_count, 2)) eq "\r") {
message_send = (substring(message_send, 1, msg_count-2))+"\n"+(substring(message_send, msg_count+2, (length(message_send))-msg_count+2));
}
}
message = message_send;
delete msg_count;
delete message_send;
loadVariablesNum("http://richmond.k12.va.us/ditflash/ditflashmail2.cfm",0,"POST";
_root.gotoAndPlay("thankyou");
}
If I make the message text input field "render as html", it will indeed send all of the text, but its html formatted, naturally, so a lot of code shows up in the email, naturally.
Thanks if anybody's actually reading this.
-Andy
hey, sorry about that.... just browsing this forum, and saw this thread again. did you get it to work?
if not, try escaping your text in the flash file, then URLDecode() in the cf script.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.