Skip to main content
Inspiring
May 4, 2010
Answered

CFMAIL - conditional help?

  • May 4, 2010
  • 2 replies
  • 1266 views

Hi - I have a form that a user submits feedback on a product and it sends an email to three people.

Is it possible to use a some conditional statement that says If product A,B,C and D is selected - send an email to person 1,2, and 3

AND if product E is selected - send email to only person 1,2,3 and 4

my code so far looks like this and the erro that I keep getting is listed below the code Thank you!

cfinsert datasource="MobWebDataSource" tablename="mobilityFeedback"
          formfields="name, email, county, product, description, phone1, phone2, phone3, ext, userComments">
         
<cfif product= gasTax, RAP, CAPP, FFC >

<CFMAIL FROM="#email#"
TO="q@crab.wa.gov"
CC="p@crab.wa.gov"
BCC="r@crab.wa.gov"
SUBJECT="FEEDBACK REPORT" SERVER="crab13">
  <cfoutput> 
#name# of #county# County has submitted a Feedback Report to CRAB Information Services.

Phone:(#phone1#) #phone2# - #phone3# ext #ext#

Product: #product#

Description: #Description#

Comments: #userComments#
</cfoutput>


</CFMAIL>       
<cfelse>

 
<CFMAIL FROM="#email#"
TO="u@crab.wa.gov, q@crab.wa.gov, p@crab.wa.gov, r@crab.wa.gov"
SUBJECT="FEEDBACK REPORT" SERVER="CRABMX">
  <cfoutput> 
#name# of #county# County has submitted a Feedback Report to CRAB Information Services.

Phone:(#phone1#) #phone2# - #phone3# ext #ext#

Product: #product#

Description: #Description#

Comments: #userComments#
</cfoutput>
</CFMAIL>

</cfif>

Invalid CFML construct found on line 85 at column 14.

ColdFusion was looking at the following text:

=

The CFML compiler was processing:

  • A cfif tag beginning on line 85, column 2.

85   <cfif product= gasTax, RAP, CAPP, FFC >

This topic has been closed for replies.
Correct answer ilssac

I added the list function but still no luck.  Condition 1 is supposed to send  the email to 3 people if the product field contains one of the values listed in the list function.

Condition 2 should send an email to four people if the product selected is not in the list function? When I click submit and choose a product in the list - the email goes to four people when it should go  only three.  Please see code. thank you.

<cfif listFind("product", "gasTax, RAP, CAPP, FFC">


<CFMAIL FROM="#email#"
TO="r@crab.wa.gov, h@crab.wa.gov, s@crab.wa.gov"
    SUBJECT="FEEDBACK REPORT"
    SERVER="CRAB1">
  
   <cfoutput>
#name# of #county# County has submitted a Feedback Report to CRAB Information Services.

Phone:(#phone1#) #phone2# - #phone3# ext #ext#

Product: #product#

Description: #Description#

Comments: #userComments#
</cfoutput>
  
  
    </CFMAIL>
  
  <cfelse>
 
     

<CFMAIL FROM="#email#"
TO="r@crab.wa.gov, h@crab.wa.gov, q@crab.wa.gov,   simo@crab.wa.gov

SUBJECT="FEEDBACK REPORT"
    SERVER="CRAB1">

     <cfoutput>
#name# of #county# County has submitted a Feedback Report to CRAB Information Services.

Phone:(#phone1#) #phone2# - #phone3# ext #ext#

Product: #product#

Description: #Description#

Comments: #userComments#
</cfoutput>
    </CFMAIL>
  
  
  
  
</cfif>


rockhiker wrote:

<cfif listFind("product", "gasTax, RAP, CAPP, FFC">

You are testing the string literal "product" against the list.  You probably meant to test the value of a variable named product.

I.E.

<cfif listFind(product,"gasTax,RAP,CAPP,FFC">

You may also want to consider the lilistFindNoCase() function so that you do not need to worry about the capitalization of the values.

The documentation for the list functions would help figure out what the best choice for you would be.

http://livedocs.adobe.com/coldfusion/8/htmldocs/functions-pt0_13.html

2 replies

Inspiring
May 4, 2010

My suggestion is to build it into your database design.  Looks like a many to many relationship.  If you don't know what that is, I've heard good things about the book, Database Design for Mere Mortals.

ilssac
Inspiring
May 4, 2010

<cfif product= "gasTax, RAP, CAPP, FFC">

Is supposed to be

<cfif product EQ "gasTax, RAP, CAPP, FFC">

But I suspect you need some type of list function in there?  That does not look like a useful comparision to me?

rockhikerAuthor
Inspiring
May 4, 2010

can you give me an example of a list function?

thank you!

ilssac
Inspiring
May 4, 2010

<cfif listFind("item","A,List,Of,Values,To,Search")>

Item is in the list

<cfelse>

Item s not in the list.

</cfif>