Java Script Email
Oct 01, 2019
Hello,
I am trying to create a JavaScript code where it pulls in the colleague's name (EEName) and am trying to send a hyperlink through the body of the email.
Can someone who is familiar with JS check over this code and see if this looks accurate? Any help would be appreciated as I am not that familiar with JS.
Thanks!
var EEName = player.GetVar('EEName');
var player = GetPlayer();
var email = player.GetVar('MgrEmail');
var subject = 'Your Offboarding Checklist for ' + 'EEName';
var emailBody = 'Hello' + '\n' + 'Please see your offboarding checklist for ' + 'EEName' + '\n' + 'https://thezone.corp.zoetis.com/hrforme/USA/_layouts/15/WopiFrame.aspx?sourcedoc={8BFB842F-3611-4BE9-8ECB-39C6B68A31A8}&file=Manager%20Separation%20Checklist_rev3_28_18.docx&action=default';
window.location.href='mailto:'+email+'?subject='+subject+'&body='+encodeURIComponent(emailBody);
6 Replies
Thank you Matthew. I tried this code out but when I try to preview it (I'm publishing as a CD and through Review 360) it's not working. Could it be something with my variables I'm using for the way I'm trying to preview?
I'm publishing as HTML5 only if that makes a difference.
Yea, sorry meant to say whenever i publish its not working for me. Ill try again tomorrow and maybe try to publish in another format. Ill also try to contact out IT dept to see if its a security issue.
Sent from my Verizon, Samsung Galaxy smartphone
You have to have an email client installed which may be the issue if you use webmail
Yea, we have outlook.
Sent from my Verizon, Samsung Galaxy smartphone
Check the developer console for error, I suspect it is variable names
Eureka !! I was able to figure it out :)
So I forgot that I created duplicated pages with the the incorrect line below and I'm assuming that is why it wasn't working.
Also, why would this code be an error? I do want to send other custom emails with URL's and other verbiage so just so I can create these other emails with ease it would be good to know some best practices when creating a custom email body with JS.
Thanks for your help!
var emailBody = 'Hello' + 'Here is your offboarding checklist to help with a smooth offboarding for' + EEName:' + '\n' + fbk;
This discussion is closed. You can start a new discussion or contact Articulate Support.