Solved

CFcatch isn't working for null email values

Posted on 2006-07-07
9
326 Views
Last Modified: 2013-12-24
Our company requires new candidates for positions to fill out an application that is attached to certain jobs.  There is one field that asks for an email address however it is not required to enter a value.

When someone does enter their email address the application works fine however if you leave it null.  You get the following error message

The following information is meant for the website developer for debugging purposes. Error Occurred While Processing Request
> Attribute validation error for tag CFMAIL.       
> The value of the attribute TO is invalid. The length of the string, 0 character(s), must be greater than or equal to 1 character(s).             
>             
> The error occurred in C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\CustomTags\ct_dohistory.cfm: line 136 Called from C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\CustomTags\ct_dohistory.cfm: line 74 Called from C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\CustomTags\ct_dohistory.cfm: line 48 Called from C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\CustomTags\ct_dohistory.cfm: line 1 Called from C:\Inetpub\wwwroot\RecruitMax\Candidates\docandidateaddupdate.cfm: line 1547 Called from C:\Inetpub\wwwroot\RecruitMax\Candidates\docandidateaddupdate.cfm: line 1512 Called from C:\Inetpub\wwwroot\RecruitMax\Candidates\docandidateaddupdate.cfm: line 1473 Called from C:\Inetpub\wwwroot\RecruitMax\Candidates\docandidateaddupdate.cfm: line 908 Called from C:\Inetpub\wwwroot\RecruitMax\Candidates\docandidateaddupdate.cfm: line 893 Called from C:\Inetpub\wwwroot\RecruitMax\Candidates\docandidateaddupdate.cfm: line 1             
> 134 :  <cfset tEmail = attributes.AppMainEmail> 135 : </cfif> 136 : <cfmail query="GetCandidates" FROM="#tEmail#" TO="#Email#" SUBJECT="#GetEmailTemplate.SubjectLine#"> 137 : #Evaluate(NEWLETTER)#    138 : </cfmail>            



There is a <cfcatch> tag that is supposed catch emails for situations like this but it doesn't work for some reason like it used to.  

Also, I would i need to mention there were a couple of things I had done before all this was created

1.  Our company upgraded from CFMX to CFMX7

2.  The original problem to this was "Trying to find out why certain data was updating in one table but not the others.

3.  To resolve the problem to comment #2 I deleted these non-negotiable questions from the database and then I commented out the code that was used to insert these non-negotiable questions into the questionnaires.

From what it looks like whether I want it to or not a candidate has to enter a value into the email form field.  So at least one value gets passed.  Does anyone have any suggestions?
0
Comment
Question by:rudodoo
  • 5
  • 3
9 Comments
 
LVL 4

Expert Comment

by:CodeParadise
ID: 17063589
I think it has to done with the #Email# variable being null. Check to see that it is assigned a valid email address.

If that doesn't solve it, could you post a portion of your code?
0
 

Author Comment

by:rudodoo
ID: 17063686
I am going through it but where exactly do you thing the value for #Email# would be
0
 

Author Comment

by:rudodoo
ID: 17063837
ok, according to the code the assigned email address is valid using a cfparam tag and assigning it a default value but this is the testing servers and would that even be a factore
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:rudodoo
ID: 17063864
I tested and my error message still pops up what portion of the code do you need to see
0
 
LVL 4

Expert Comment

by:CodeParadise
ID: 17064054
I guess we could try with the code leading up to the <cfmail> along with the <cftry> and <cfcatch>.
0
 

Author Comment

by:rudodoo
ID: 17064204
Ok, what is happening is that there is <cfmail> <Cftry> and <cfcatch> tags inserted in to the code but for some reason its  not reading them.  Here is the code.  Also keep in mind this used to work.  

<!--- Send E-Mail for New Externals --->
                                          <cfquery name="email" datasource="#DSN#">
                                                Select email from Candidates
                                                Where CandidateID = '#Val(tCandidateID)#'
                                          </cfquery>
                                          <cfquery name="jobtitle" datasource="#DSN#">
                                                Select jobtitle from Orders
                                                Where OrderID = '#szOrderID#'
                                          </cfquery>
                                          <cftry>
                                          <cfmail to="#email.email#" from="corp.staffing@Company.com" subject="REQUISITION #szOrderID# - #jobtitle.jobtitle#">


This message is to confirm that Company has received your application for requisition #szOrderID# - #jobtitle.jobtitle#.
                  
Company has retained the services of Company Background America (Company) as a background screening vendor.  As a result, you may be directed to their web site and asked to provide additional information.  This information is kept confidential by Company, and is not accessible by Company or any other organization.  Furthermore, information furnished to Company will be used only if an offer of employment is extended to you.
                  
Please continue to visit us frequently as our job site is updated daily with new opportunities.  Thanks again for exploring employment with Company!
                                          </cfmail>
                                           <cfcatch type="any">
                                          </cfcatch>
                                          </cftry>
                        <cfelse>
                              <cftry>
                              <!--- Send an email to the administrator advising that there was not Candidate Applied history category --->
                              <!--- to use for this workgroup so no history will show up for this candidate --->
                               <cfmail FROM="#DSN#"
                                          TO="#DSN#"
                                          SUBJECT="Unable to create candidate history">
                                          The candidate history could not be created for #GetCandidate.FirstName# #GetCandidate.LastName#
                                          because there was no History Category marked for New Web Candidates.
                              </cfmail>
                              <cfcatch type="any">
                              </cfcatch>
                              </cftry>
                        </cfif>
                  </cfif>
            </cfif>
      </cfif
0
 

Author Comment

by:rudodoo
ID: 17065220
Is it possible to insert an 'if' statement that tells coldfusion to use the same <cfcatch> tag if the value in the email is null
0
 
LVL 12

Expert Comment

by:mmc98dl1
ID: 17070630
the error is on line 136 <cfmail query="GetCandidates" FROM="#tEmail#" TO="#Email#" SUBJECT="#GetEmailTemplate.SubjectLine#">

So the error is caused by attributes.AppMainEmail being null. Where is this coming from?
0
 
LVL 4

Accepted Solution

by:
CodeParadise earned 500 total points
ID: 17077045
rudodoo,

I was able to recreate your error and I still believe that is has to do with the #Email# variable being null. If you want a null email value to be caught with your <cfcatch> then use the following inside your <cftry> tags and before your <cfmail> tags.


<cfif email EQ "">
    <cfthrow type="any">
</cfif>
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question