ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 6th, 2012, 05:10 PM
Matttolman Matttolman is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 2 Matttolman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 19 sec
Reputation Power: 0
Cfmail to certain addresses depending on form data

I have a form I need to send via cfmail to certain addresses depending on the first letter of the last name on the form being submitted. I am a new to coldfusion in need of some help. not sure how to go about it. I have some code, but as I said I am new to coldfusion and was tasked with this project. I don't expect someone to do it for me, I just would appreciate some help of any kind.

I am limited to Coldfusion 5 also.

Code:
<cfif Left(form.LAST_NAME, A,B,C,D,E,F,G,H)>
	      <CFMAIL TO="person1@bob.org"
	        FROM="#form.EMAIL#"
	        etc...
	      </CFMAIL>
	<cfelseif Left(form.LAST_NAME, I,J,K,L,M,N,O,P)>
	      <CFMAIL TO="person2@bob.org"
	        FROM="#form.EMAIL#"
	        etc...
	      </CFMAIL>
	<cfelseif Left(form.LAST_NAME, Q,R,S,T,U,V,W,X,Y,Z) >
	      <CFMAIL TO="person3@bob.org"
	        FROM="#form.EMAIL#"
	        etc...
	      </CFMAIL>
	<cfelse>
	      <CFMAIL TO="person4@bob.org"
	        FROM="#form.EMAIL#"
	        etc...
	      </CFMAIL>
	</cfif>



Please Help! Thanks in advance.

Reply With Quote
  #2  
Old February 7th, 2012, 12:03 AM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
The first thing you'll want to do is check the docs, because that's not how the Left() function works.

First I would simplify this with a basic regular expression, something like:

Code:
 
<cfif REFindNoCase("[a-h]", form.last_name)>...


Second, you can avoid having to duplicate the entire cfmail tag by using a variable for the email address. So something like:

Code:
<!--- Default email --->
<cfset email = "person4@bob.org" />

<cfif REFindNoCase("[a-h]", form.last_name)>...
	<cfset email = "person1@bob.org" />
<cfelseif REFindNoCase("[i-p]", form.last_name)>
	<cfset email = "person2@bob.org" />
<cfelseif REFindNoCase("[q-z]", form.last_name)>
	<cfset email = "person3@bob.org" />
</cfif>

<cfmail to="#email#".....>


Hope that helps.

Reply With Quote
  #3  
Old February 7th, 2012, 10:17 AM
Matttolman Matttolman is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 2 Matttolman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 19 sec
Reputation Power: 0
Thank you so much for the help. This also helps me understand ColdFusion better too.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Cfmail to certain addresses depending on form data

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap