Try this on the Flex-side (the modified CFC function [see below] returns a 
Boolean):

public function recoverPassword(eventObj:ResultEvent):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</cfif>' 
                </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:ResultEvent):void{
              
              if(eventObj.result.status == 'true'){
                          Alert.show(eventObj.result.statusMsg, 'Password 
Recovery Confirmation');
                          currentState = '';
                      }
                      else{
                          Alert.show(eventObj.result.errMsg, '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</cfif>' 
                  </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:ResultEvent):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:ResultEvent):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/Undelivr.

  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/discussion%40affug.com/

List hosted by http://www.fusionlink.com

-------------------------------------------------------------

Reply via email to