Help with JavaScript: Group multiple text variables and send it as an email

Oct 06, 2022

Hi everyone,

I have 7 slides in this course, each slide has one text input and a text variable to store this input.  

In the last slide, display all 7 text variables to users, and let users send all text as an email. 

I got everything working except for two bugs:

1. The default email client on my computer does not fire up if I write too many words, no matter if it's in one variable or spread words to multiple variables, maybe around 2500 characters. Does the variable have character limit?

Code below:

var player = GetPlayer();

var useremail=player.GetVar("Email");

var note1=player.GetVar("note1");
var note2=player.GetVar("note2");
var note3=player.GetVar("note3");
var note4=player.GetVar("note4");
var note5=player.GetVar("note5");
var note6=player.GetVar("note6");
var note7=player.GetVar("note7");

var subject="Questions";

var questions=note1+note2+note3+note4+note5+note6+note7;

var content="Hi,%0d%0A%0d%0A";

content+=questions;

var mailto_link='mailto:'+useremail+'?subject='+subject+'&body='+content;

win=window.open(mailto_link,'emailWin');

2. There is no line break between variables in the email body. Perhaps we have to rely on users to hit extra enter.

https://360.articulate.com/review/content/46b10788-a4a2-4abd-9b20-fb1899ab4451/review

Thanks a lot!

8 Replies
Tianxuan Liu

Thanks, Sandeep.

The code doesn't work.

First, the body text goes to the subject line of the email. 〒▽〒

Second, the SEND EMAIL button doesn't fire up the default email client on my computer If I write too many words.

For example, copy the below lorem into questions 1 and 2. Go to the last slide, click on send email, and my outlook will start.

But copy more lorem to questions 3 and 4, go to the last slide, no response from send email button.  I just don't understand this. 

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).

Tianxuan Liu

Hi Sandeep,

I modified your code. The email subject and body are working now. The linebreak in the email is also working, thank you.

The linebreak on the "COPY" function doesn't work. I don't worry about it right now.

Now I am going to see why Outlook doesn't start up.

Sandeep Gadam
I'm happy to hear that using the code I gave you, you were able to proceed. At first, I omitted the subject from the code I gave you and just made sure the text entries were printed in the email the way you wanted them to. I'm not aware of the text printing inside the subject block. I am sorry for my oversight.
 
I'll have a look at the linebreak on the COPY function and see what I can do.
Brian Anderson

We're running into the exact same issue with the email window not firing once we've reached a particular character limit with the mailto - it seems to be around 2,300 characters.  @Luciana, I don't know if this is possible, but would there be a way we could find out the solution Lianne provided Tianxuan for this problem?

Jose Tansengco

Hello Brian, 

I checked the support case and it appears that Liane verified a bug where Javascript triggers for launching a new email message don't work if the body contains 1540 characters or more. We're still working on this issue and we'll let everyone subscribed to this thread know as soon as a fix is released!