Forum Discussion

MollyFisher-dd0's avatar
MollyFisher-dd0
Community Member
4 years ago

Javascript - send text box entry to body text of email

Hi all,

I want to use Javascript so that when a learner clicks "Submit," their email opens with their email address filled in, and the text entry contents to be in the body of the email.

I can open an email with a predetermined email address, subject and body text, but I'm struggling to populate the variables. My Javascript doesn't work when I call the Player.

My project is attached. Thanks!!

2 Replies

  • Replying to myself because I worked out an almost solution:

    var player = GetPlayer();
    var email=player.GetVar("tomail");
    var subject=player.GetVar("subject");
    var bodytxt=player.GetVar("Goals");
    var start = player.GetVar("body_start");

    var mailto_link='mailto:'+email+'?subject='+subject+'&body='+start+bodytxt+"%0d%0A";

    win=window.open(mailto_link,'emailWin');

     

    So I can successfully populate the variables! But now my issue is to create a page break after the body_start text.

  • Hi, Molly.

    I'm happy you were able to figure out how to populate the variables in your e-mail. 

    Take a look at the discussion below for some suggestions on adding line breaks to your code:

    I hope this helps!