Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

send email based on answers

  • srn122
  • srn122's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 11 months ago #199828 by srn122
send email based on answers was created by srn122
Hello,

I am using Version 3.6.1+180329.

I have a short survey with 4 yes/no questions and an email field.

Is it possbile to send an email to the email address completed by user?

There will be two scenarios:
-in case of all yes answers send an email
-if one or more no answers send a different email.

Thank you
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 11 months ago #199829 by Joffm
Replied by Joffm on topic send email based on answers
Use one of the notification emails.

let's say "Send basic admin notification email to:"
In the email field enter {Q_email} with "Q_email" as code of your email question.

In the email body you use "micro-tayloring" to enter the texts.
E.g.
{if(Q1=="Y" AND Q2=="Y" AND Q3=="Y" AND Q4=="Y","Text of 4 YES answers","Text of 1 or more NO answers")}

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu, cdorin, srn122
The topic has been locked.
  • srn122
  • srn122's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 11 months ago #199871 by srn122
Replied by srn122 on topic send email based on answers
Thank you for your reply,

I have managed to do something but I only receive empty emails.

I tried different ways but same results.

i used question codes(Q1, Q2..), question codes with curly brackets({Q1}, {Q2}..) with answer codes with or without curly brackets(Q1A1, {Q2A1}...) or exact string as you mentioned Q1=="Nu" but always empty emails.

And I dont see what I am doing wrong.

Are there some explanations as to what type of coding I should enter to make it work?

I ve tried looking at this manual section but it didnt help me: manual.limesurvey.org/Expression_Manager#Qcode_Variable_Naming


Thank you
The topic has been locked.
More
3 years 11 months ago #199872 by cdorin
Replied by cdorin on topic send email based on answers
Better provide an .lss file to see what you did so far :)

Manual: manual.limesurvey.org/LimeSurvey_Manual
Bugs tracker: bugs.limesurvey.org/my_view_page.php
If you self-host and need help, contact one of our partners: limesurvey.com
Please do not contact me via PM - thank you.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 11 months ago #199884 by Joffm
Replied by Joffm on topic send email based on answers
Hi,
see here:
manual.limesurvey.org/ExpressionScript_H..._in_invitation_email
and
manual.limesurvey.org/ExpressionScript_-...#Access_to_variables

exact string as you mentioned Q1=="Nu"

Nowhere I mentioned this.
{if(Q1=="Y" AND Q2=="Y" AND Q3=="Y" AND Q4=="Y","Text of 4 YES answers","Text of 1 or more NO answers")}

To find out how these predefined question types (Y/N, Gender, array(Yes/No/Unsure),..) are coded, you should activate a small sample survey with these question types, enter some data, and look at the answer table.

But nevertheless: as cdorin: Send your lss export.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • srn122
  • srn122's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 10 months ago #199907 by srn122
Replied by srn122 on topic send email based on answers
here is the lss.

File Attachment:

File Name: limesurvey...1489.lss
File Size:21 KB
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago - 3 years 10 months ago #199908 by Joffm
Replied by Joffm on topic send email based on answers
2. mistakes

1. The syntax of this IF-statement is wrong_
{if({Q3}=="Nu" AND {Q4}=="Nu" AND {Q5}=="Nu" AND {Q6}=="Nu","No Answer text","Yes Answer text")}
Can't you copy what I wrote?

2. You have to compare with CODE of answer option, NOT text of answer option
In your first post you talked about "Yes/No" question.
Therefore this statement compares with the code of a "Yes/No" question.

{if(Q1=="Y" AND Q2=="Y" AND Q3=="Y" AND Q4=="Y","Text of 4 YES answers","Text of 1 or more NO answers")}


But now I see that you use a list radio. So you have to use these codes.
So obviously you have to use:
{if(Q1=="A1" AND Q2=="A1" AND Q3=="A1" AND Q4=="A1","Text of 4 YES answers","Text of 1 or more NO answers")}

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 10 months ago by Joffm.
The topic has been locked.
  • srn122
  • srn122's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 10 months ago #199946 by srn122
Replied by srn122 on topic send email based on answers
I ve said I tried all possible combination, including your expression, the one you saw was probably just the last attempt.

Anyway, now it works, thank you.

But I have another issue: Can I add text with html tags inside the email body?

The second email won't be just a phrase.
Now I have something like this on the 'source' tab, and in place of formatted text I receive only blank email:


<html>
<head>
<title></title>
</head>
<body>{if(Q3=="A1" AND Q4=="A1" AND Q5=="A1" AND Q6=="A1","TEXTTEXTTEXT","TEXTTEXTTEXTT
<ul>
<li>OPTION1OPTION1.</li>
<li>OPTION2OPTION2</li>
<li>OPTION3OPTION3.</li>
</ul>
")}</body>
</html>
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago #200019 by holch
Replied by holch on topic send email based on answers

Can I add text with html tags inside the email body?


Yes.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • srn122
  • srn122's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 10 months ago #200025 by srn122
Replied by srn122 on topic send email based on answers
I meant inside the text of the two different emails messages.
As I tried with the unordered list, but it doesnt show.
As I said when I try it only sends blank emails.

I hope I explained it well
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago #200031 by DenisChenu
Replied by DenisChenu on topic send email based on answers
Mail was set as html ?
Can you reproduce on a sample light lss ?
If yes : report issue

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • srn122
  • srn122's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 10 months ago #200038 by srn122
Replied by srn122 on topic send email based on answers

DenisChenu wrote: Mail was set as html ?


I think it is by default. Where is this option?

Can you reproduce on a sample light lss ?


I uploaded an lss earlier.
Or do you mean something else?

If yes : report issue

The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose