Chris, I think this might be what you need after thinking a bit more about the issue you described. Some background info is included (I apologize if it seems verbose).
I created a test Flex app (it's Flex 4/Flash Builder 4) and a single function CFC to emulate what you're trying to accomplish. I found (and I remember that this is something that has existed in Flex/CF since at least Flex 1.5) that when you try to pass a simple Flex Object as a CF struct (I did not see how you are actually calling the CFC in your Flex app, but suspect you are trying to pass a Flex Object as a single entity to CF), you need to apply a bit of 'black magic' - passing an extra parameter in the remote object call or CF will complain that the struct is required but was not passed in (Element FORM_DATA.EMAIL is undefined in ARGUMENTS). Of course you think you're passing the object to CF, and you are, but "Notice Coldfusion didnt treat the Flex object as 1 argument" (according to this link: http://www.joelconnett.com/flexobjectstocoldfusion.html). The technique I usually use is shown below (it is just easier to type): You can pass in a dummy extra parameter like I have in the code below (note the '' empty string that I pass to the CFC function in line 24: <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" creationComplete="appLoaded()" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Declarations> <mx:RemoteObject id="roTest" destination="ColdFusion" endpoint="http://localhost/flex2gateway/" source="prototypes.test" showBusyCursor="true"> <mx:method name="recoverPassword" result="recoverPasswordHandler(event)" fault="roFaultHandler(event)"/> </mx:RemoteObject> </fx:Declarations> <fx:Script> <![CDATA[ import mx.controls.Alert; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; import mx.utils.ObjectUtil; private function appLoaded(): void { var objUser:Object = new Object(); objUser.email = '[email protected]'; line 24 roTest.recoverPassword(objUser, ''); } private function recoverPasswordHandler(eventObj:ResultEvent): void { if (eventObj.result){ Alert.show('Your credentials have been sent to the email address on file.', 'Password Recovery Confirmation'); } else { Alert.show('The email address that you supplied was not found in our records.', 'Email Not Found'); r } } private function roFaultHandler(event:FaultEvent): void { Alert.show(ObjectUtil.toString(event.fault)); } ]]> </fx:Script> </s:Application> The CFC I used, test.cfc is shown below (* NOTE: you would need to modify the cfquery section to match your database and cfadmin datasource) <cfcomponent output="false"> <!--- Password Retrieval ---> <cffunction name="recoverPassword" access="remote" returntype="boolean"> <cfargument name="form_data" type="struct"> <cfset var accountCheck=""> <cftry> <cfquery datasource="your_datasource" name="accountCheck"> SELECT clientEmail, clientName, tmppassword FROM sometable WHERE clientEmail = '#arguments.form_data.email#' </cfquery> <cfif accountCheck.recordcount> <cfmail from="[email protected]" to="#accountCheck.clientEmail#" subject="Credentials Request" type="html"> Dear #accountCheck.clientName#, <br /><br /> You have requested that we send your login credentials for the system on #DateFormat(now(), 'MMMM DD, YYYY')#. <br /><br /> Your log-in information:<br /> <b>Email address:</b> #accountCheck.clientEmail#<br /> <b>Password:</b> #accountCheck.tmppassword# <br /><br /> If you did not request your login credentials, please contact us immediately at <a href="mailto:[email protected]">[email protected]</a>:<br /><br /> <span style="color:red; font-weight:bold; font-style:italic;">Please do not reply to this email</span> </cfmail> <cfreturn true/> <cfelse> <cfreturn false/> </cfif> <cfcatch> <cfsavecontent variable="contentSaver"> <cfdump var="#cfcatch#"> </cfsavecontent> <cffile action="write" file="#ExpandPath('.')#\debug.html" output="#contentSaver#"> <cfreturn false/> </cfcatch> </cftry> </cffunction> </cfcomponent> Of note, I tried the "http://www.joelconnett.com/flexobjectstocoldfusion.html link" technique three too, and that also worked for me. private function appLoaded(): void { var objUser:Object = new Object(); objUser.email = '[email protected]'; var objWrapper:Object = new Object(); objWrapper = {form_data : objUser}; roTest.recoverPassword(objWrapper); } Regards, Mike > -------- Original Message -------- > Subject: Re: [AFFUG Discuss] Newbie questions on Flex for email > notification and form review > From: "[email protected]" <[email protected]> > Date: Thu, June 03, 2010 11:57 am > To: [email protected] > > 1. Declaring/initializing your query name is a best practice. Do a > google search about why setting vars in CFC functions is a good idea for > a better answer or maybe somebody else can chime in on this one? > > 2. I missed that you would need to return a boolean in the catch, so > thanks to the CF server for the reminder to both of us, but I would > return a false, since it means that the email did not get sent. As to > the cfmail mechanics and why the try is catching an error, are you 100% > certain you are not blowing up with any syntax errors in the try portion > of your code? What does the catch message your writing out say? > Also, test cfmail with a simple test case where the email address is > hard-coded to your own address and watch the spool folder. You can do a > quick copy and paste from the cf spool folder to your desktop, tamper > with it in a text editor in some way that will prevent the cf server > from successfully sending the email, save the file, and paste it back to > the cf spool folder - this should test your third-party respooler. Once > you're convinced it works, delete the intentionally mangled email file > you created. All of this said, is to ensure that cfmail and your > third-party tool are talking to each other. > > Back to your cfmail tag in your CFC function... double-check that your > db query is returning the data you think it is by trying the query > outside the function - something as innocent-appearing as a misnamed > columm name could be wreaking havoc. Is email the column name? I'm not > looking at your code as I type this, but maybe your > queryname.recordcount eliminates that possibility, but the bottomline is > the try is failing, so as I mentioned what you capture in your catch > section should help - you can play with the type of catch and say 'all' > so u see what type of error you are getting. > > Finally on the Flex-side of things my suggested code was to help get rid > of the null object exception - by passing true or false from your CFC > function, you will get one of your alerts (now that you pass a boolean > in your catch block too - return a false though if the try fails. > > > Hope this helps some. > > Mike > > > -------- Original Message -------- > > Subject: Re: [AFFUG Discuss] Newbie questions on Flex for email > > notification and form review > > From: Chris H <[email protected]> > > Date: Thu, June 03, 2010 8:19 am > > To: [email protected] > > > > > > Hi Michael, > > Thanks for the reply. > > Two points I did not > > understand. > > 1. Why did we need a <cfset > > var accountCheck=""> on the > > CF side when there was a query > > named accountcheck as > > <cfquery > > datasource="#Application.ds#" > > name="accountCheck"> > > SELECT > > email, fname, lname, password > > FROM > > user_accounts > > WHERE > > email = > > '#form_data.email#<cfif > > form_data.email does not > > contain > > '@domain.com'>@domain.com</cfi > > f>' > > </cfquery> > > What was the reason for adding > > a variable accountCheck? > > Because in the if block in the > > CF side we are testing <cfif > > accountCheck.recordcount> > > which was based on the result > > of above query so is there any > > reason/purpose for setting > > accountCheck to empty string? > > 2. On the CF side cfmail is > > failing in the try block as > > there is no mail server so it > > was going to the catch block > > where no true/false was being > > returned so I got the message > > "Unable to invoke CFC > > recoverPassword as the return > > type is not boolean. I added a > > <cfreturn true /> in the > > catch part and the error > > message disappeared. > > Since in the recoverPassword > > on the Flex side, the > > eventObj.result is not being > > modified in CFC > > recoverPassword it has value > > false and so we go into the > > else part where I get the > > message Alert.show(''The email > > address that you supplied was > > not found in our records.", > > 'Email Not Found'); > > I saw nothing was present in > > SpoolMail to. My intent was to > > test if the cfmail > > functionality works and if so > > the undelivered mails should > > be displayed using a > > SpoolMail, but they are not. > > How do I know now if the > > cfmail worked properly or not? > > Can you please clarify? > > Sorry, if my questions are > > naive, but I am pretty new to > > ColdFusion/Flex. > > Thanks > > _________________________ > > From: Michael Givens > > <[email protected]> > > To: [email protected] > > Sent: Wed, June 2, 2010 > > 6:48:32 PM > > Subject: Re: [AFFUG Discuss] > > Newbie questions on Flex for > > email notification and form > > review > > Try this on the Flex-side (the > > modified CFC function [see > > below] returns a Boolean): > > public function > > recoverPassword(eventObj:Resul > > tEvent):void{ > > if > > (eventObj.result){ > > Alert.show(''Your credentials > > have been sent to the email > > address on file.', 'Password > > Recovery Confirmation'); > > currentState = ''; > > } else { > > Alert.show(''The email address > > that you supplied was not > > found in our records.', 'Email > > Not Found'); > > } > > } > > On the CF-side: > > <!--- Password Retrieval > > ---> > > <cffunction > > name="recoverPassword" > > access="remote" > > returntype="boolean"> > > <cfargument > > name="form_data" > > type="struct"> > > <cfset var > > accountCheck=""> > > <cftry> > > <cfquery > > datasource="#Application.ds#" > > name="accountCheck"> > > SELECT > > email, fname, lname, password > > FROM > > user_accounts > > WHERE > > email = > > '#form_data.email#<cfif > > form_data.email does not > > contain > > '@domain.com'>@domain.com</cfi > > f>' > > </cfquery> > > <cfif > > accountCheck.recordcount> > > <cfmail > > from="[email protected]" > > to="#accountCheck.email#" > > subject="Credentials Request" > > type="html"> > > Dear > > #accountCheck.fname# > > #accountCheck.lname#, <br > > /><br /> > > You > > have requested that we send > > your login credentials for the > > system on #DateFormat(now(), > > 'MMMM DD,YYYY')#. > > <br > > /><br /> > > Your > > log-in information:<br /> > > <b>Email address:</b> > > #accountCheck.email#<br /> > > <b>Password:</b> > > #accountCheck.password# > > <br > > /><br /> > > If you > > did not request your login > > credentials, please contact us > > immediately at <a > > href="mailto:[email protected]" > > >[email protected]</a>: > > <br > > /><br /> > > <span > > style="color:red; > > font-weight:bold; > > font-style:italic;">Please do > > not reply to this email</span> > > </cfmail> > > <cfreturn > > true /> > > <cfelse> > > <cfreturn > > false/> > > </cfif> > > > > <cfcatch> > > <cfsavecontent > > variable="contentSaver"> > > > > <cfdump var="#cfcatch#"> > > </cfsavecontent> > > <cffile > > action="write" > > file="#ExpandPath('.')#\debug. > > html" output="#contentSaver#"> > > </cfcatch> > > </cftry> > > </cffunction> > > ----- Original Message ----- > > From: Chris H > > To: [email protected] > > Sent: Thursday, June 03, 2010 > > 3:19 AM > > Subject: Re: [AFFUG Discuss] > > Newbie questions on Flex for > > email notification and form > > review > > Tom, > > Whenever my application tries > > to send a mail using the > > CFMAIL functionality it either > > crashes or no mails show up in > > SpoolMail. > > Before I installed SpoolMail, > > my Coldfusion/Flex application > > was crashing due to reference > > to a null object eventObj > > which made me think that since > > I have no mail server > > installed, it is occurring > > when CFMAIL tries to send an > > email and posted here on May > > 26. > > The application has a > > functionality something like > > the below for Recovering > > password function. > > User clicks a button in the > > Flex front end, enters his > > mail address, after which a > > function called > > recoverPassword is called in > > the "login.mxml" file which > > has code as > > public function > > recoverPassword(eventObj:Resul > > tEvent):void{ > > > > if(eventObj.result.status == > > 'true'){ > > Alert.show(eventObj.result.sta > > tusMsg, 'Password Recovery > > Confirmation'); > > currentState = ''; > > } > > else{ > > Alert.show(eventObj.result.err > > Msg, 'Email Not Found'); > > } > > } > > In the ColdFusion component > > file, there is a function > > <!--- Password Retrieval > > ---> > > <cffunction > > name="recoverPassword" > > access="remote" > > returntype="any"> > > <cfargument > > name="form_data" > > type="struct"> > > <cftry> > > <cfquery > > datasource="#Application.ds#" > > name="accountCheck"> > > SELECT * > > FROM > > user_accounts > > WHERE > > email = > > '#form_data.email#<cfif > > form_data.email does not > > contain > > '@domain.com'>@domain.com</cfi > > f>' > > </cfquery> > > <cfif > > accountCheck.recordcount> > > <cfmail > > from="[email protected]" > > to="#accountCheck.email#" > > subject="Credentials Request" > > type="html"> > > Dear > > #accountCheck.fname# > > #accountCheck.lname#, <br > > /><br /> > > You > > have requested that we send > > your login credentials for the > > system on #DateFormat(now(), > > 'MMMM DD,YYYY')#. > > <br > > /><br /> > > Your > > log-in information:<br /> > > <b>Email address:</b> > > #accountCheck.email#<br /> > > <b>Password:</b> > > #accountCheck.password# > > <br > > /><br /> > > If you > > did not request your login > > credentials, please contact us > > immediately at <a > > href="mailto:[email protected]" > > >[email protected]</a>: > > <br > > /><br /> > > <span > > style="color:red; > > font-weight:bold; > > font-style:italic;">Please do > > not reply to this email</span> > > </cfmail> > > <cfset > > result['status'] = true> > > <cfset > > result['statusMsg'] = 'Your > > credentials have been sent to > > the following email address: > > #accountCheck.email#'> > > <cfelse> > > <cfset > > result['errMsg'] = 'The email > > address that you supplied was > > not found in our records.'> > > <cfset > > result['status'] = false> > > </cfif> > > > > <cfreturn result> > > <cfcatch> > > <cfsavecontent > > variable="contentSaver"> > > > > <cfdump var="#cfcatch#"> > > </cfsavecontent> > > <cffile > > action="write" > > file="#ExpandPath('.')#\debug. > > html" output="#contentSaver#"> > > </cfcatch> > > </cftry> > > </cffunction> > > Before I installed SpoolMail > > the application crashed at > > public function > > recoverPassword(eventObj:Resul > > tEvent):void as the eventObj > > was null so trying to access > > eventObj.result.status > > resulted in an access > > violation. > > After I installed SpoolMail it > > is still crashing and nothing > > shows up in SpoolMail. I > > commented out the function > > public function > > recoverPassword(eventObj:Resul > > tEvent):void, but still > > nothing shows up in SpoolMail. > > Am I missing something? > > Any advice would be > > appreciated? > > Thanks > > _________________________ > > From: Tom McNeer > > <[email protected]> > > To: [email protected] > > Sent: Wed, May 26, 2010 > > 4:53:39 PM > > Subject: Re: [AFFUG Discuss] > > Newbie questions on Flex for > > email notification and form > > review > > Chris, > > On Wed, May 26, 2010 at 4:10 > > PM, Chris H > > <[email protected]> wrote: > > I tried Spoolmail, but could > > not see any section named > > Custom Extensions in the > > ColdFusion Administrator in my > > browser(Firefox 3.6) after I > > copied the Spoolmail files > > into the web root at: > > /CFIDE/admistrator and > > creating the > > extensionscustom.cfm as > > explained in the install.doc > > file. > > I'm afraid I have no way of > > knowing the problem. If the > > files are in the correct > > place, the "Custom Extensions" > > menu choice should be > > available at the bottom of the > > left-hand menu in CF Admin. > > Clicking it will reveal the > > SpoolMail link. > > In extensions section in the > > Coldfusion administrator, all > > I see is Java Applets, CFX > > Tags, Custom Tag Paths, CORBA > > Connectors > > Yep. But that's the wrong > > place. The "Custom Extensions" > > choice is separate from > > "Extensions." It's probably > > the last choice in the > > left-hand menu. > > If you're certain that all > > files are correct, and in the > > correct place, I guess you > > could try restarting the CF > > service. The SpoolMail docs > > don't mention it, and I can't > > imagine why it should be > > necessary, but you could try > > it. > > I've installed SpoolMail on > > several machines. If it's set > > up correctly, it always works. > > Next, Spoolmail is used for > > reading mail only meaning an > > email server is required for > > testing and Spoolmail will be > > helpful in reading it? > > Or, is no mail server required > > if using Spoolmail? > > You don't need a mail server. > > The actual mail message is > > created and formatted properly > > by the CFMAIL functionality. > > If ColdFusion cannot connect > > to a mail server, it places > > the message in its > > "undelivered" folder. You can > > find it at > > {CFInstallDirectory}/Mail/Unde > > livr. > > SpoolMail just looks into this > > directory and displays what's > > there. > > -- > > Thanks, > > Tom > > Tom McNeer > > MediumCool > > http://www.mediumcool.com > > 1735 Johnson Road NE > > Atlanta, GA 30306 > > 404.589.0560 > > --------------------------- > > --------------------------- > > ------- > > To unsubscribe from this > > list, simply email the list > > with unsubscribe in the > > subject line > > For more info, see > > http://www.affug.com > > Archive @ > > http://www.mail-archive.com > > /discussion%40affug.com/ > > List hosted by FusionLink > > --------------------------- > > --------------------------- > > ------- > > ------------------------------ > > ------------------------------ > > - > > To unsubscribe from this list, > > simply email the list with > > unsubscribe in the subject > > line > > For more info, see > > http://www.affug.com > > Archive @ > > http://www.mail-archive.com/di > > scussion%40affug.com/ > > List hosted by FusionLink > > ------------------------------ > > ------------------------------ > > - > > ------------------------------ > > ------------------------------ > > - > > To unsubscribe from this list, > > simply email the list with > > unsubscribe in the subject > > line > > For more info, see > > http://www.affug.com > > Archive @ > > http://www.mail-archive.com/di > > scussion%40affug.com/ > > List hosted by FusionLink > > ------------------------------ > > ------------------------------ > > - > > > > ------------------------------------------------------------- > To unsubscribe from this list, simply email the list with unsubscribe in the > subject line > > For more info, see http://www.affug.com > Archive @ http://www.mail-archive.com/discussion%40affug.com/ > List hosted by http://www.fusionlink.com > ------------------------------------------------------------- ------------------------------------------------------------- To unsubscribe from this list, simply email the list with unsubscribe in the subject line For more info, see http://www.affug.com Archive @ http://www.mail-archive.com/discussion%40affug.com/ List hosted by http://www.fusionlink.com -------------------------------------------------------------
