Solved

Sending email to selected recipients

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

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

838 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