Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda