Send results slide via email using Javascript ??

Hello!  I'm pretty new to... well... all of this, but I'm a fast learner.  I've been toying around with adding Javascript to my Storyline project for some advanced capabilities, and so far I've figured out how to execute an email with HTML5.  I understand that there are issues with mobile and Flash.

So my question is: is it possible to set up Javascript within my Storyline project that will email an image of the results slide/certificate of completion? 

It would be great if the image could be in the body of the email, but I would also be happy if it were an attachment.  I don't know if it is possible to set it up so that once the user lands on the results/completion slide, there is an image automatically generated and included in the email.... again, pretty new at this. =)

Here is my current set up (for my test project) including code:

  • I set up a text entry called "EmailAddress"  - the user will enter their desired email addresses in here.
  • I have a text variable called "EmailAddress"
  • I added a trigger to a button that will execute Javascript when the user clicks.

This is the Javascript I'm using:

var player = GetPlayer();
var course="Storyline test course"
var email=player.GetVar("EmailAddress");
var subject="Assessment Complete";
var body_start="I've just completed my assessment!";
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;
win=window.open(mailto_link,'emailWin');

Please note: I've patched my JS together from information I've found within these forums and on the web.  I don't know how to write JS or all the rules, but I can usually figure out how to use it if I play around with it for long enough.

Any help would be amazing, and thank you so much in advance... and sorry if this question has already been covered; I wasn't able to find an answer anywhere. =)

29 Replies
Ashley Terwilliger

Hi Vandana,

You may want to begin by reviewing the information here in regards to the Javascript best practices as that'll be what is needed to get this set up. It's not something our team can assist with, so you're also welcome to contact Travis or others in this thread directly using the "contact me" button on their profiles to see if they're able to share additional information with you here. 

DLD 1

Hi all,

If trying to use the above to do the email but also post the score the user gets. I've modified the code and added a variable but I don't know what I'm doing wrong. Can someone please check this out for me?

var player = GetPlayer();
var email='email@gmail.com';
var score=player.GetVar('percent');
var subject="Assessment Complete";
var body_start = 'Here is my percentage:' +score;
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;
win=window.open(mailto_link,'emailWin');

 

Catherynne Mattar

Hi DLD 1

Your code was perfect for what I wanted - email the player score (and name). Perhaps your problem is in the GetVar('percent') line - do you have a variable called 'percent'? Here's my script, based on yours:

var player = GetPlayer();
var email='bogus@gmail.com';
var score=player.GetVar('UserScore');
var name=player.GetVar('UserName');
var subject='Assessment Complete for: ' +name;
var body_start = 'Here is my score: ' +score;
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;
win=window.open(mailto_link,'emailWin');

As you can see, I've created two variables - UserScore and UserName. I've got triggers on each slide (Scenario template layout) to add different values to the UserScore var depending on their choice. On the Feedback slide, I've used a normal template feedback layout, but replaced the built-in var with my own, i.e. %UserScore% - which presents the total score of all choices on all slides. That var is then pulled into my email.

This is a perfect solution to not being able to pass scenario values to my LMS... so thankyou!