Sending email to selected recipients

Posted on 2006-11-08
Medium Priority
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">
                    <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>
                    <td>Name<span class="style1">*</span></td>
                    <td><cfinput name="name" type="text" id="name" value="" required="yes" message="Please enter Name"></td>
                    <td><cfinput name="company" type="text" id="company"></td>
                    <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>
                    <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>
                    <td><textarea name="comments" cols="40" rows="4"></textarea></td>
                    <td><input name="Submit" type="submit" id="Submit" value="Send Email"></td>

then within thankyou.cfm I have:

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

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


<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>

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

Any help would be appreciated.

Question by:gardena
  • 2
LVL 15

Accepted Solution

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

<cfswitch expression="#contact#">

Author Comment

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

Expert Comment

ID: 17896516
Thanks, glad I could help.


Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
From store locators to asset tracking and route optimization, learn how leading companies are using Google Maps APIs throughout the customer journey to increase checkout conversions, boost user engagement, and optimize order fulfillment. Powered …
If you are looking for an automated tool which can generate reports for Outlook emails and other items from PST file, then you can go for Kernel PST Reporter tool. The reports which are created by this tool are helpful to analyze and understand PST …

597 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