?
Solved

Sending email to selected recipients

Posted on 2006-11-08
3
Medium Priority
?
194 Views
Last Modified: 2013-12-24
Hi I have a form with an option to send to various recipients. I have used this setup before on another server without any problems:

<cfform action="thankyou.cfm" method="post" enctype="multipart/form-data" name="Enquiry Form">
                   <p>Fields shown with an <span class="style1">* </span>are compulsory. </p>
                   <table width="100%" border="1" cellpadding="3" cellspacing="0" bordercolor="#003333" class="mainbodytext">
                  <tr>
                    <td width="34%">I want to email </td>
                    <td width="66%"><select name="contact">
                      <option value="Rep">Rep</option>
                      <option value="Chairman">Chairman</option>
                      <option value="Secretary">Secretary</option>
                      <option value="Treasurer">Treasurer</option>
                    </select>                    </td>
                  </tr>
                  <tr>
                    <td>Name<span class="style1">*</span></td>
                    <td><cfinput name="name" type="text" id="name" value="" required="yes" message="Please enter Name"></td>
                  </tr>
                  <tr>
                    <td>Company</td>
                    <td><cfinput name="company" type="text" id="company"></td>
                  </tr>
                  <tr>
                    <td>Phone<span class="style1">*</span></td>
                    <td><cfinput name="phone" type="text" id="phone" value="" required="yes" message="Please enter your phone number"></td>
                  </tr>
                  <tr>
                    <td>Email<span class="style1">*</span></td>
                    <td><cfinput name="email" type="text" id="email" value="" required="yes" message="Please enter your email address"></td>
                  </tr>
                  <tr>
                    <td>Comments</td>
                    <td><textarea name="comments" cols="40" rows="4"></textarea></td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td><input name="Submit" type="submit" id="Submit" value="Send Email"></td>
                  </tr>
                </table></cfform>

then within thankyou.cfm I have:

<cfif ISDefined("recipient")>
      <cfset sendTo = recipient>
<cfelse>

      <cfswitch expression="contact">
      <cfcase value="Rep">
               <cfset sendTo = "rep@dot.com">
      </cfcase>
      <cfcase value="Chairman">
               <cfset sendTo =  "chairman@dot.com">
      </cfcase>
      <cfcase value="Secretary">
               <cfset sendTo =  "secretary@dot.com">
      </cfcase>
      <cfcase value="Treasurer">
               <cfset sendTo =  "treasurer@dot.com">
      </cfcase>
      <cfdefaultcase>
               <cfset sendTo =  "default@dot.com">
      </cfdefaultcase>
      </cfswitch>

</cfif>

<cfmail to="#sendTo#" from="#email#" subject="Enquiry From Website" type="html">
Name: <strong>#name#</strong><br>
Phone: <strong>#phone#</strong><br>
Comments:<strong> #comments#</strong><br>
</cfmail>

On testing it keeps sending to "default@dot.com" and I can't see why...

Any help would be appreciated.

0
Comment
Question by:gardena
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
tim_cs earned 1000 total points
ID: 17896439
Try adding the #'s to your cfswitch

<cfswitch expression="#contact#">
0
 
LVL 1

Author Comment

by:gardena
ID: 17896512
Yep that seems to have done it... :-)
0
 
LVL 15

Expert Comment

by:tim_cs
ID: 17896516
Thanks, glad I could help.

Tim
0

Featured Post

Supports up to 4K resolution!

The VS192 2-Port 4K DisplayPort Splitter is perfect for anyone who needs to send one source of DisplayPort high definition video to two or four DisplayPort displays. The VS192 can split and also expand DisplayPort audio/video signal on two or four DisplayPort monitors.

Question has a verified solution.

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

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…
What You Need to Know when Searching for a Webhost Provider
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

765 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