Solved

CFcatch isn't working for null email values

Posted on 2006-07-07
9
328 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
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Forbidden errors 5 152
Setting Up Local Lan Web Server 1 64
performance tune IIS 10 on win 2016 that only runs one website 4 122
Email not working after mx record created 8 43
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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