Email Trigger

Apr 13, 2020

I want to launch an Outlook email message with a cc: to a different person and have the following javascript.  Its not working.  Can anyone tell me what is wrong with the coding?

var email="bill.nye@scienceguy.com"
var cc="jill.nye@scienceguy.com";
var subject="Clothes - Science Experiment";
var body_start="Please provide me with the following.
Polo size
Jacket size
Gender
Quantity
Name
Address
City
State
Zip
Phone
Thank you.";
var mailto_link='mailto:' +email +'?cc=' +cc +'&subject= '+subject+'&body=' +body_start;
win=window.open(mailto_link,'emailWin');

Also, I have similar code in that works in a version of this same project that does work, but when I copy/paste that code in this newer version just to test it it does not work.  The older file is about 36 MB the newer one is 78 MB.  Are there other parameters that would not make this javascript work if the code is fine?

Thank you.

 

6 Replies
Ned Whiteley

Hi Donna,

I am certainly no javascript expert (as in I don't use it at all), but simply looking at the basics and I know this is stating the blindingly obvious (but that's often where we all make the simplest of mistakes), but have you checked that your trigger to execute your javascript is correctly set and hasn't set itself to "unassigned" when you have copied the script over?

Vincent Scoma

Hi Donna, 

Happy to help! 

While we don't provide support for JavaScript coding, I wanted to jump in to see if I could point you in the right direction.

I reviewed the code you provided and found that I kept receiving an error in Chrome's developer tools. It looks like there was an issue with the variable: var body_start, so I tried reformatting that line to see if that would help: 

After changing the format of that variable, the Execute Javascript trigger launched outlook and showed the following: 

I would suggest focusing on the variable: var body_start, so it is formatted to your preference. I also wanted to share this guide that I believe will help as well: 

I am hoping others in the community will also share their insights! 

Walt Hamilton

I found that this script worked in Gmail to keep your formatting the way you want it:

var email="bill.nye@scienceguy.com"
var cc="jill.nye@scienceguy.com";
var subject="Clothes - Science Experiment";
var body_start="Please provide me with the following. %0D%0A Polo size %0D%0A Jacket size %0D%0A Gender %0D%0A Quantity %0D%0A Name %0D%0A Address %0D%0A City %0D%0A State %0D%0A Zip %0D%0A Phone %0D%0A %0D%0A Thank you.";
var mailto_link='mailto:' +email +'?cc=' +cc +'&subject= '+subject+'&body=' +body_start;
win=window.open(mailto_link,'emailWin');

Lauren Cawley

I currently have a trigger set to execute JavaScript to send an e-mail template. The code I am currently using works perfectly:

var email="directreportsaddress@email.com";
var subject="type your subject here";
var body_start="type your text here";
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;
win=window.open(mailto_link,'emailWin');

However, I need to add an image (not a whole slide) to the body of the email. To do this do I need to create a URL of the image to input in my JavaScript? (And if so, what coding would I use to insert the URL) or would I be able to create a variable with the image? And if so, what would I add to my script?

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