Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sending email to selected recipients

Posted on 2006-11-08
3
Medium Priority
?
197 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

610 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