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

139
Views
How to open .eml file instead of downloading with javascript

I am working on a requirement where I need to open html formatted email after clicking on a button in a html page. After reviewing different technics I found below solution which creates an .EML file.

funcion openEmail() {
    var emailTo='test@gmail.com';
    var emailSubject='Dummy Subject';
    var emlContent = "data:message/rfc822 eml;charset=utf-8,";
    
    emlContent += 'To: '+emailTo+'\n';
    emlContent += 'Subject: '+emailSubject+'\n';
    emlContent += 'X-Unsent: 1'+'\n';
    emlContent += 'Content-Type: text/html'+'\n';
    emlContent += ''+'\n';
    emlContent += '<b>Dummy Content</b>';
    
    var encodedUri = encodeURI(emlContent); //encode spaces etc like a url
    var a = document.createElement('a'); //make a link in document
    var linkText = document.createTextNode("fileLink");
    a.appendChild(linkText);
    a.href = encodedUri;
    a.id = 'fileLink';
    a.download = 'test.eml';
    a.style = "display:none;"; //hidden link
    document.body.appendChild(a);`enter code here`
}

But I need to open it directy with configured email application. like outlook, gmail etc. I tried mailto , location things but formatted email is not possible there.

about 4 years ago · Juan Pablo Isaza
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!