Javascript - sending an email to more than one recipient.

Mar 29, 2017

Hi,

We are trying to work out how to send an email to more than one address when the user clicks a button in our course. The bulk of the code below brings in variables from the course, depending on what a user has selected for a particular question.

The code below loads the user's email window successfully, however in the "To" field on the email screen, we only have cc@gladsolutions.co.uk so far.

We would like to know how to add more email addresses to the 'To' field. We have tried adjusting the line var email, but no luck.  Things we have tried include:

var email = 'cc@gladsolutions.co.uk'; 'mt@gladsolutions.co.uk'

var email = 'cc@gladsolutions.co.uk', 'mt@gladsolutions.co.uk';

See below for the Javascript we currently have. There are some mailto words at the bottom of the code too and maybe we need to adjust this too?:

var player = GetPlayer();
var email = 'cc@gladsolutions.co.uk';
var uname = player.GetVar('userName');
var aboutyou2 = player.GetVar('IssueAboutYou2Added');
var aboutyou9 = player.GetVar('IssueAboutYou9Added');
var aboutyou10 = player.GetVar('IssueAboutYou10Added');
var DSE1 = player.GetVar('IssueDSE1Added');
var DSE2 = player.GetVar('IssueDSE2Added');
var DSE3 = player.GetVar('IssueDSE3Added');
var DSE4 = player.GetVar('IssueDSE4Added');
var DSE6 = player.GetVar('IssueDSE6Added');
var DSE7 = player.GetVar('IssueDSE7Added');
var DSE8 = player.GetVar('IssueDSE8Added');
var DSE9 = player.GetVar('IssueDSE9Added');
var Environment1 = player.GetVar('IssueEnvironment1Added');
var Environment2 = player.GetVar('IssueEnvironment2Added');
var Environment3 = player.GetVar('IssueEnvironment3Added');
var Environment4 = player.GetVar('IssueEnvironment4Added');
var Environment5 = player.GetVar('IssueEnvironment5Added');
var Environment6 = player.GetVar('IssueEnvironment6Added');
var Furniture3 = player.GetVar('IssueFurniture3Added');
var Furniture4 = player.GetVar('IssueFurniture4Added');
var Furniture5 = player.GetVar('IssueFurniture5Added');
var Furniture6 = player.GetVar('IssueFurniture6Added');
var Furniture7 = player.GetVar('IssueFurniture7Added');
var Furniture8 = player.GetVar('IssueFurniture8Added');
var WorkTasks2 = player.GetVar('IssueWorkTasks2Added');
var WorkTasks3 = player.GetVar('IssueWorkTasks3Added');
var subject = 'Workstation Assessment Results';
var emailBody = 'Dear Facilities Department,' + '\n' + '\n' + uname + ' has completed the Workstation Assessment and has indicated that they have the following issues:' + '\n' + '\n' + 'ABOUT YOU Issues:' + '\n' + 'Suffers from an RSI: ' + aboutyou2 + '\n' + 'Has an issue with workstation layout: ' + aboutyou9 + '\n' + 'Requires training to adjust furniture/equipment: ' + aboutyou10 + '\n' + '\n' + 'FURNITURE Issues:' + '\n' + 'Chair is unstable: ' + Furniture3 + '\n' + 'Chair has issues moving: ' + Furniture4 + '\n' + 'Chair is in poor condition: ' + Furniture5 + '\n' + 'Chair height cannot be adjusted: ' + Furniture6 + '\n' + 'Desk space in unsuitable: ' + Furniture7 + '\n' + uname + ' would like a document holder: ' + Furniture8 + '\n' + '\n' + 'ENVIRONMENT Issues:' + '\n' + 'There is an issue with the lighting: ' + Environment1 + '\n' + 'There is an issue with the temperature: ' + Environment2 + '\n' + 'There is an issue with the humidity: ' + Environment3 + '\n' + 'There is an issue with the noise level: ' + Environment4 + '\n' + 'There is an issue with the space around your workstation: ' + Environment5 + '\n' + 'There is an issue with the filing and/or storage space nearby: ' + Environment6 + '\n' + '\n' + 'WORK TASKS Issues:' + '\n' + uname + ' would like a new mouse: ' + WorkTasks2 + '\n' + uname + ' would like an ergonomic keyboard: ' + WorkTasks3 + '\n' + '\n' + 'DSE Issues:' + '\n' + 'Unable to adjust brightness on monitor: ' + DSE1 + '\n' + 'Monitor is flickering: ' + DSE2 + '\n' + 'Monitor height cannot be adjusted: ' + DSE3 + '\n' + 'Monitor is too close or too far: ' + DSE4 + '\n' + uname + ' works exclusively on a laptop: ' + DSE6 + '\n' + 'Keyboard tilt cannot be adjusted: ' + DSE7 + '\n' + 'Keyboard symbols are no longer visible: ' + DSE8 + '\n' + 'Not enough space in front of keyboard: ' + DSE9 + '\n' + '\n';
var mailto_link = 'mailto:' + email + '?subject=' + subject + '&body=' + encodeURIComponent(emailBody);
win = window.open(mailto_link, 'emailWin');

 

Any help would be much appreciated.

 

 

3 Replies

This discussion is closed. You can start a new discussion or contact Articulate Support.