Is there a way using Javascript to pull variables in the subject line of email and into email body? Also, is there a way to send content such as PDF files through email using JS as well?

Sep 26, 2019

Hello,

I am working on an interactive offboarding checklist that managers are able to fill out and at the end will be able to view a "personalized" checklist where I would like them to be able to email it to themselves and to also email materials to the colleague they are offboarding. That being said, I am having some trouble trying to put in a JS code to pull this off (I'm new to JS so you might have to bear with me a bit) but doesn't seem like it's working. 

I have 4 variables I need to use:

1. The manager's email ('MgrEmail')

2. The colleague's name ('EEName")

3. The colleague's email ('EEEmail')

4. The checklist (I want to see if I can send this as an attachment on the email but wasn't sure if possible to put this as a variable somewhere in the course)

This is the code that I am working off of right now where the manager can send the checklist to themselves and will develop one where the manager can sent to the colleague, but for now this is what I have. It also looks like I'm not able to pull in any variables into the subject line like the colleague's name and having trouble with modifying the body of the email.

var player = GetPlayer();
var email = player.GetVar('MgrEmail');
var fbk = player.GetVar('Feedback'); <- this part is where I want to place the offboarding checklist
var EEName = player.GetVar('EEName');
var subject = 'Your Offboarding Checklist for ' + 'EEName';
var emailBody = 'Hello' + 'Here is your offboarding checklist to help with a smooth offboarding for' + EEName:' + '\n' + fbk; <- Checklist
window.location.href='mailto:'+email+'?subject='+subject+'&body='+encodeURIComponent(emailBody);

 

Can someone take a look at this and tell me what I might be doing wrong and to advise on how I can send content (the checklist) through this email?

Unfortunately I cannot share the source code since it is for my company but if you need me to provide anything else just let me know. Thanks!

 

-Kevin

Be the first to reply

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