CFcatch isn't working for null email values

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?
rudodooAsked:
Who is Participating?
 
CodeParadiseConnect With a Mentor Commented:
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
 
CodeParadiseCommented:
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
 
rudodooAuthor Commented:
I am going through it but where exactly do you thing the value for #Email# would be
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
rudodooAuthor Commented:
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
 
rudodooAuthor Commented:
I tested and my error message still pops up what portion of the code do you need to see
0
 
CodeParadiseCommented:
I guess we could try with the code leading up to the <cfmail> along with the <cftry> and <cfcatch>.
0
 
rudodooAuthor Commented:
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
 
rudodooAuthor Commented:
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
 
mmc98dl1Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.