Forum Discussion
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. =)
30 Replies
- khajamuzaffarudCommunity Member
Hello can anyone say me how to add a html file to mail attachment by using javascript?
- DLD1Community Member
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');- CatherynneMattaCommunity Member
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!
- RickPitmanCommunity Member
I am creating a course that is a new hire "check-in" for a weekly update on progress. Essentially each week the learner will log in and complete a short status update on specific categories with their supervisor. Here is my JS, but i just simply doesn't run. Any help would be appreciated!
var player = GetPlayer();
var email = "myemail@email.com";
var subject = "SSE Day 1" ;
var ee_id = Player.GetVar(EEIDNumber);
var Super = Player.GetVar(SupervisorName);
var Super_ID = Player.GetVar(Super_ID);
var Safety = Player.GetVar(Safety_Rating);
var Instructions = Player.GetVar(Inst_Rating);
var Productivity = Player.GetVar(Productivity_Rating);
var Teamwork = Player.GetVar(Teamwork_Rating);
var Proff = Player.GetVar(Proff_Rating);
var Feedback = Player.GetVar(Feedback);
var body_start = "The following answers are from the course";
var body_middle1 = "EE ID: ";
var body_middle2 = "Supervisor Name: ";
var body_middle3 = "Supervisor ID: ";
var body_middle4 = "Safety Rating: ";
var body_middle5 = "Following Instructions: ";
var body_middle6 = "Productivity: ";
var body_middle7 = "Teamwork: ";
var body_middle8 = "Professionalism: ";
var body_middle9 = "Feedback: ";
var cr = "\n";
var body_end = "Please save these answers in an email folder for future reference.\n";
var mailto_link = 'mailto:' +email+'?subject='+subject+'&body='+encodeURIComponent(body_start +body_middle1 +EE_ID +cr +body_middle2 +Super +cr +body_middle2 +Super +cr +body_middle3 +Super_ID +cr +body_middle4 +Safety +cr +body_middle5 +Instructions +cr +body_middle6 +Productivity +cr +body_middle7 +Teamwork +cr +body_middle8 +Proff +cr +body_middle9 +Feedback +cr + body_end);
win = window.open(mailto_link, 'emailWin')