Forum Discussion
Javascript for sending Storyline 360 text entries via email
Within SL, I've been trying to initiate an email via javascript that contains text entry content, but I cannot get it to work. Essentially, I want the learner to be able to send their notes to themselves/others in an email.
I get halfway there: I'm able to generate a new browser tab (via each of the below separate sets of java), but no Outlook email generates. Each of them, when tested separately, only opens a Chrome browser tab.
What am I doing wrong? I need it to generate an Outlook email.
JAVA 1
var player = GetPlayer();
var email='';
var subject='Tracks Course Notes';
var feedback=player.GetVar('MyNotes');
var emailBody = +feedback
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+encodeURIComponent(emailBody);
win=window.open(mailto_link,'emailWin');
--------------------------
JAVA 2
var player = GetPlayer();
var useremail=player.GetVar("Email");
var subject="Tracks Training Notes";
var notes1=player.GetVar("MyNotes");
var content="Tracks Training Notes%0d%0A%0d%0A";
content+=notes1;
var mailto_link='mailto:'+useremail+'?subject='+subject+'&body='+content;
win=window.open(mailto_link,'emailWin');
-------------------------------
JAVA 3
var player = GetPlayer();
var email=player.GetVar("Email");
var subject="Tracks Training Feedback";
var body_start=player.GetVar("MyNotes");
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+escape(body_start);
emailwin=window.open(mailto_link,'emailWin');
emailwin=window.close();
- MargharitaNe202Community Member
I have this jarascript code in storyline, and I'm trying to eliminate the cc and bcc fields and customize the subject line to read: self-assessment results. Any help is greatly appreciated. I've been researching and trying different code, but given my limited knowledge of JS, nothing seems to work.
Player = GetPlayer();
var SendEmail = Player.GetVar("SendEmail")
var cc = Player.GetVar("carbonCopy")
var bcc = Player.GetVar("B_carbonCopy")
var Subject = Player.GetVar("EmailSubject")
var Primary = Player.GetVar("Primary");
var FirstName = Player.GetVar("Competing");
var LastName = Player.GetVar("Accommodating");
var StudentID = Player.GetVar("Compromising");
var StudentEmail = Player.GetVar("Avoiding");
var Student = Player.GetVar("Collaborating");
var sBody = "Your primary style: " + Primary + "\r\n\r\n";
sBody += "Competing: " + FirstName + "\r\n\r\n";
sBody += "Accommodating: " + LastName + "\r\n\r\n";
sBody += "Compromising: " + StudentID + "\r\n\r\n";
sBody += "Avoiding: " + StudentEmail + "\r\n\r\n";
sBody += "Collaborating: " + Student + "\r\n\r\n";
sBody = encodeURIComponent(sBody);
window.location.href = "mailto:" + SendEmail + "?cc=" + cc + "&bcc=" + bcc + "&subject=" + Subject + "&body=" + sBody; - WaltHamiltonSuper Hero
Margharita,
There is a similar question here:
https://community.articulate.com/discussions/articulate-storyline/javascript-in-storyline-360
one of the answers towards the bottom may help you.