Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

79
Views
how can i get this javascript to work? how to set up a carbon copy gmail?

basically, ive been trying to set up this code for my page, however im struggling as im not the best at javascript. ive tried looking up resources online but none of them seem to help. this is part of a form, i want the users to fill a small form and then, after clicking the button, it should open their mail client with a template. i just need to know how to properly add the information to the javascript, especially how to set up a carbon copy gmail, and if theres anything i should change. i can provide the full form code if needed.

<div class="row">
<input type="submit" value="Enviar." onclick="sendMail(); return false">
</div>

heres the javascript that ive been working with

<script>

function sendMail() {
    var link = "mailto:me@example.com"
             + "?cc=myCCaddress@example.com"
             + "&subject=" + encodeURIComponent("This is my subject")
             + "&body=" + encodeURIComponent(document.getElementById('myText').value)
    ;
    
    window.location.href = link;
}

</script>
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

mailto is one of many URL Protocols and it's a way for commands to exit the browser and interact with other applications.

you can try this URL API

https://mail.google.com/mail/?view=cm&fs=1&to=[to]&cc=[cc]&bcc=[bcc]&su=[subject]&body=[body]

Although not recommended. Anyone who clicks on it needs to be logged into their gmail account (if they have one), but technically it works if the user has gmail and is logged in.

here is an example on how to combine urls

const combination = (obj) => {
  const parameter = Object.entries(obj).map(o => `&${o[0]}=${o[1]}`).join('');
  return `https://mail.google.com/mail/?view=cm&fs=1${parameter}`
};

const mail1 = {
  su: 'subject',
  to: 'someone',
  body: 'body',
  cc: 'someone',
  bcc: 'someone'
}

const mail2 = {
  su: 'subject',
  to: 'someone',
  body: 'body'
}

console.log('mail1', combination(mail1));
console.log('mail2', combination(mail2));

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!