Jump to content

Send Email based on drop down selection


TwiztedCupid

Recommended Posts

Hi. I want to send an email to a specific person based on the selection made in a drop down list. I'm using Dreamweaver CS4 and Adobe Developer Toolbox for the existing code. Here is some of my code.

 

This first part is where it sends the mail. I need to use the variable in the "setTo" line. I know if I use {Services} it will send it to the values selected in drop down. i.e. Tree@yahoo-inc.com; Service@yahoo-inc.com.

 

function Trigger_SendEmail(&$tNG) {
  $emailObj = new tNG_Email($tNG);
  $emailObj->setFrom("webmaster@somewhere.com");
  $emailObj->setTo("VARIABLE HAS TO GO HERE");
  $emailObj->setCC("me@you.com");
  $emailObj->setBCC("");

 

Here is the code for the select:

 

<select name="Services" id="Services">
            <option value=""  <?php if (!(strcmp("", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Select a service...</option>
            <option value="Landscape Maintenance" <?php if (!(strcmp("Landscape Maintenance", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Landscape Maintenance</option>
            <option value="Landscape Design" <?php if (!(strcmp("Landscape Design", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Landscape Design</option>
            <option value="Planting Renovation" <?php if (!(strcmp("Planting Renovation", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Planting Renovation</option>
            <option value="Tree Service" <?php if (!(strcmp("Tree Service", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Tree Service</option>
              <option value="Snowplowing" <?php if (!(strcmp("Snowplowing", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Snowplowing</option>
<option value="Other" <?php if (!(strcmp("Other", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Other</option>
            </select>

 

Is there a way if the user selects "Landscape Maintenance" or "Landscape Design" the email will go to "user1@somewhere.com". If they select "Tree Service" it will go to "user2@somewhere.com"? Something like:

 

If Services = "Landscape Design" Or "Landscape Maintenance" Then
         $toEmail = "user1@somewhere.com"
   Else
   If Services = "Tree Service" Then
        $toEmail = "user2@somewhere.com"......and so on.

 

Then place $toEmail into "$emailObj->setTo("$toEmail");"?

 

Link to comment
Share on other sites

You could do something like this..

 

$emails_array = array(
'Landscape Maintenance'=>'email1@email.com',
'Landscape Design'=>'email2@email.com',
'Planting Renovation'=>'email3@email.com',
'Tree Service'=>'email4@email.com',
'Snowplowing'=>'email5@email.com',
'Other'=>'email6@email.com');

function Trigger_SendEmail(&$tNG) {
  global $emails_array;
  $emailObj = new tNG_Email($tNG);
  $emailObj->setFrom("webmaster@somewhere.com");
  $emailObj->setTo($emails_array[$_POST['Services']]);
  $emailObj->setCC("me@you.com");
  $emailObj->setBCC("");
}

 

Not 100% certain but it should work :P

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.