Send email according to option select

christallo 18 May, 2015
Is ther a way to send 2 different email replys to 2 different user groups? So that a student gets a different reply then a "normal"user?
There was a post with different emails but I need 2 different email content.

THX, Axel
GreyHead 19 May, 2015
Hi christallo,

You can use an Event Switcher action with a different email action in each event.

Bob
christallo 20 May, 2015
Thks Bob.

Is it this code what you wrote in another similar post?:
    <?php
    switch ($form->data['radio_99'] ) {
      case 'some_value':
        $form->data['email_template'] = ". . . {some_input} . . .";
        break;
      case 'some_other_value':
        $form->data['email_template'] = ". . . {some_other_input} . . .";
        break;
    } 
    ?>

Then add {email_template} to the Email template.



- Put the code with a Custom Element into the Form? With 'radio_99' is my option button, 'email_template1' is the first email - in my case Email#2 and 'email_template2' could be the second email (Email#3)?
- And than add {email_template1} to Email#2 and {email_template2} to Email#3?

Does that make sense? I'm quite not sure where to put what......

Thanks a lot!
GreyHead 20 May, 2015
Hi Axel,

That's a slightly different way to do it. That approach uses one Email action and changes the template (or parts of the template). I was suggesting that you use two different Email actions.

Either approach will work, which is best depends on the Email content and who you want to send them to.

If the emails are very different then I'd suggest that you use two emails; if you just need to change part of the template then one email is OK.

The code you found goes into a Custom Code action before the Email action.

Bob
christallo 25 May, 2015
Thanks Bob.

But that doesn't work....

In my form, I have a radio button "input_radio_18" with the options:
Ordentliches Mitglied=Ordentliches Mitglied
Förderndes Mitglied=Förderndes Mitglied
Studentisches Mitglied=Studentisches Mitglied
Juristisches Mitglied=Juristisches Mitglied

I put the code in a custom element right before the send button:
 <?php
    switch ($form->data['input_radio_18'] ) {
      case 'Ordentliches Mitglied':
        $form->data['Ordentliches Mitglied'] = ". . . {email_template1} . . .";
        break;
      case 'Studentisches Mitglied':
        $form->data['Studentisches Mitglied'] = ". . . {email_template2} . . .";
        break;
    } 
    ?>


Than I put the {email_template1} in front of the #email2 template, and the {email_template2} in front of the #email3 template.

But that does not work - it sends both mail replies to the sender.
I also tried to use one email and put {email_template1} in front of the first text an {email_template2} after that text in front of the next text.....no succes.
What do I wrong?

Best, Axel
GreyHead 26 May, 2015
Hi Axel,

Your code is not the same as mine. I used $form->data['email_template'] in both cases.

What exactly do you need to do?

Bob
christallo 26 May, 2015
I need to send a user a different email content regarding the option of my radio button:
Ordentliches Mitglied=Ordentliches Mitglied
Förderndes Mitglied=Förderndes Mitglied
Studentisches Mitglied=Studentisches Mitglied
Juristisches Mitglied=Juristisches Mitglied

So when a user clicks "Studentisches Mitglied" he should get a slight different email than the others.
GreyHead 26 May, 2015
Hi Axel,

The code that I posted should let you do that. Can you give an example of 'slightly different'?

Bob
christallo 26 May, 2015
Hi Bob.
The first email should be:

vielen Dank für ihr Interesse an einer Mitgliedschaft.

Für eine Mitgliedschaft als studentisches Mitglied benötigen wir:
1. Mitgliedsantrag mit Unterschrift (nur postalisch möglich)
→formlos, oder Formular vom Flyer; wichtig ist die Unterschrift
2. Aktuelle Studienbescheinigung (postalisch oder per e-mail)
Siehe dazu § 3.2 der Satzung

Die Unterlagen schicken Sie bitte an:
- adress -
Wenn Sie noch Fragen haben, können Sie mich gerne kontaktieren.
Telefonisch bin ich in der Regel Do. und Fr. Vormittag gut zu erreichen.

Herzliche Grüße
sender


the second email:

vielen Dank für ihr Interesse an einer Mitgliedschaft.
Für eine Mitgliedschaft als ordentliches Mitglied benötigen wir:
1. Mitgliedsantrag mit Unterschrift (nur postalisch möglich)
→formlos, oder Formular vom Flyer; wichtig ist die Unterschrift
2. Lebenslauf (postalisch oder per e-mail)
3. Nachweise ihrer Ausbildung (postalisch oder per e-mail)
4. Nachweise über künstlerische und gesangspädagogische Tätigkeiten (postalisch oder per e-mail)
(Siehe dazu § 3.1 der Satzung)
Die Unterlagen schicken Sie bitte an:
- adress -
Wenn Sie noch Fragen haben, können Sie mich gerne kontaktieren.
Telefonisch bin ich in der Regel am besten Do. und Fr. Vormittag zu erreichen.
Herzliche Grüße
-sender-



So it's just in the middle part different....
GreyHead 26 May, 2015
Hi Axel,

Please try this. In the Custom Code:
<?php
switch ( $form->data['input_radio_18'] ) {
  case 'Studentisches Mitglied':
    $form->data['mitglied'] = 'studentisches';
    $form->data['section_2'] = '<p>2. Lebenslauf (postalisch oder per e-mail)<br />
3. Nachweise ihrer Ausbildung (postalisch oder per e-mail)<br />
4. Nachweise über künstlerische und gesangspädagogische Tätigkeiten (postalisch 
oder per e-mail) (Siehe dazu § 3.1 der Satzung)</p>';
    $form->data['am_besten'] = '';
    break;
  default:
    $form->data['mitglied'] = 'ordentliches';
    $form->data['section_2'] = '<p>2. Aktuelle Studienbescheinigung (postalisch oder per e-mail) Siehe dazu § 3.2 der Satzung)</p>';
    $form->data['am_besten'] = 'am besten ';
    break;
} 
?>
and in the email template:
vielen Dank für ihr Interesse an einer Mitgliedschaft.
Für eine Mitgliedschaft als {mitglied} Mitglied benötigen wir: 
1. Mitgliedsantrag mit Unterschrift (nur postalisch möglich)→formlos, 
oder Formular vom Flyer; wichtig ist die Unterschrift
{section_2}
Die Unterlagen schicken Sie bitte an:
- adress -Wenn Sie noch Fragen haben, können Sie mich gerne kontaktieren.
Telefonisch bin ich in der Regel (am_besten}Do. und Fr. Vormittag gut zu erreichen.
Herzliche Grüßesender
This probably need some more HTML tags . . .

Bob
christallo 27 May, 2015
Sorry, Bob.

With the code in a custom element (pure code), the form does not show up - just the "powered by chronoforms..."link.

(If we can get this to work, I will be happy to write a short tutorial for this problem, what might come up often for other chronoform users)

Axel
GreyHead 27 May, 2015
Hi Axel,

There was a missing ' - now fixed; and the code goes into a Custom Code action in the form On Submit event before the Email action (not in a Custom Code element).

Bob
christallo 28 May, 2015
Ho Bob.

Thanks - now it works! I just had to switch the content. And I was able to add the other options, so that I now have 4 different email replies!
I buy you a coffee!

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