The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> ColdFusion Development
|
Cfmail to certain addresses depending on form data
Discuss Cfmail to certain addresses depending on form data in the ColdFusion Development forum on Dev Shed. Cfmail to certain addresses depending on form data ColdFusion Development forum discussing CFML coding practices, tips on CFML, and other CFML related topics. Find out why ColdFusion is the tool of choice for many e-commerce developers.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 6th, 2012, 05:10 PM
|
|
Registered User
|
|
Join Date: Feb 2012
Posts: 2
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.
|

February 7th, 2012, 12:03 AM
|
|
Moderator
|
|
Join Date: Jun 2002
Location: Raleigh, NC
|
|
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.
|

February 7th, 2012, 10:17 AM
|
|
Registered User
|
|
Join Date: Feb 2012
Posts: 2
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. 
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|