Solved

CFcatch isn't working for null email values

Posted on 2006-07-07
9
322 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
Comment Utility
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
Comment Utility
I am going through it but where exactly do you thing the value for #Email# would be
0
 

Author Comment

by:rudodoo
Comment Utility
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
 

Author Comment

by:rudodoo
Comment Utility
I tested and my error message still pops up what portion of the code do you need to see
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 4

Expert Comment

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

Author Comment

by:rudodoo
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now