mailto link with HTML body

前端 未结 10 1903
攒了一身酷
攒了一身酷 2020-11-21 22:26

I have a couple of mailto links in a HTML document.


Can I insert HTML formatted body in the <

10条回答
  •  南笙
    南笙 (楼主)
    2020-11-21 23:18

    It's not quite what you want, but it's possible using modern javascript to create an EML file on the client and stream that to the user's file system, which should open a rich email containing HTML in their mail program, such as Outlook:

    https://stackoverflow.com/a/27971771/8595398

    Here's a jsfiddle of an email containing images and tables: https://jsfiddle.net/seanodotcom/yd1n8Lfh/

    HTML

    
     


    Javascript

    (function () {
    var textFile = null,
      makeTextFile = function (text) {
        var data = new Blob([text], {type: 'text/plain'});
        if (textFile !== null) {
          window.URL.revokeObjectURL(textFile);
        }
        textFile = window.URL.createObjectURL(data);
        return textFile;
      };
    
      var create = document.getElementById('create'),
        textbox = document.getElementById('textbox');
      create.addEventListener('click', function () {
        var link = document.getElementById('downloadlink');
        link.href = makeTextFile(textbox.value);
        link.style.display = 'block';
      }, false);
    })();
    

提交回复
热议问题