0

I am running javascript on a form that collects comments and then an email address. The user can type comments (note7) and then email them to the address they enter. However, I want the mailto action to open a gmail message window, instead of the user's default mail client. Once the blank gmail message is opened, I want to populate it with the comments and the address that come from the form.

Here is what I have tried (which only opens a message in the default client):

var player = GetPlayer();
var emailAddress = player.GetVar("emailAddress");
var note7 = player.GetVar("note7");

var subject = "Journal Notes";
var emailBody = note7
var mailto_link = 'mailto:' + emailAddress + '?subject=' + subject + '&body=' + encodeURIComponent(emailBody);
win = window.open(mailto_link, 'emailWin'); 

Any help with this javascript?

  • Yes, it can be done using javascript: var player = GetPlayer(); var emailAddress = player.GetVar("emailAddress"); var note7 = player.GetVar("note7"); var subject = "Journal Notes"; var emailBody = note7 var mailto_link = “https://mail.google.com/mail/?view-cm&fs=1" + '&to=' + emailAddress + '&subject='+ subject + '&body=' + emailBody; win = window.open(mailto_link, 'emailWin'); – KnotJen Mar 09 '23 at 14:06
  • Actually, I just found a way to do it: `location.assign("https://mail.google.com/mail/?view=cm&fs=1&to=email@domain.example")` - hope this helps. – Parking Master Mar 09 '23 at 14:21

0 Answers0