Solved

Sending email to selected recipients

Posted on 2006-11-08
3
185 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
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
tim_cs earned 250 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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now