Solved

Sending email to selected recipients

Posted on 2006-11-08
3
187 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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.
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

773 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