I'm using angular to do the following.
How to dynamically generate a text file with some dynamic contents (some what like following)
dynamic_text() {
return "dynamic text goes here...";
}
download_file(name, contents, mime_type) {
mime_type = mime_type || "text/plain";
var blob = new Blob([contents], {type: mime_type});
var dlink = document.createElement('a');
dlink.download = name;
dlink.href = window.URL.createObjectURL(blob);
dlink.onclick = function(e) {
// revokeObjectURL needs a delay to work properly
var that = this;
setTimeout(function() {
window.URL.revokeObjectURL(that.href);
}, 1500);
};
dlink.click();
dlink.remove();
}
and then attach it to mail
window.location.href = `mailto:${recepient}?subject=${subject}&body=${body}`;
So that as the user calls the methods it will automatically generate the file with dynamic content and then downloads it & then attaches to the mail/
Though I'm using angular, it is more relate to javascript. So anyone can help!
How to achieve something like this?