Forums

Two versions of email depending on formvalues

alinden 13 Feb, 2014
Hi,

What is the best way to make it possible to send one of two existing emails as a reply of a formsubmit. So, e.g. if a radiobutton has a value 1 --> email 1 is send, if it has the value 2 --> email 2 is send.

Kind regards, Aron.
GreyHead 13 Feb, 2014
Hi Aron,

Is this the same email to different addresses? or different email to the same address? or different emails to different addresses?

Bob
alinden 13 Feb, 2014
This is a different email to the same address. Zo depending on what the visitor filled in the form either one of two emails is send.
GreyHead 13 Feb, 2014
Hi alinden,

I would handle that by using PHP in a Custom Code action before the email action, something like this:
<?php
if ( $form->data['radiop_button_name'] == 'some_value' ) {
  $email_body ="
  Some text {$form->data['some_input_name']} more text . .  .
";
} else {
  $email_body ="
  Some other  text {$form->data['some_other_input_name']} some more text . .  .
";
}
$form->data['email_body'] = $email_body;
?>
Then put {email_body} in the Email template.

You could also put the PHP in the Email template if you have the Rich text editor turned off but I prefer to separate it out.

Also, if part of the email remains the same, you can mix and match making just a part of the template variable in this way.

Bob
This topic is locked and no more replies can be posted.