0


Copying different files into the input such as xlxs, png, msg, etc. works perfectly. What I wish to accomplish is being able to copy mails directly from Outlook into the input (as msg-files).

The problem:

If I copy a mail from Outlook with the current solution I get vague information such as the subject, sent date, receiver etc - Just as if you would paste the clipboard into notepad.

The Goal:

If you copy a mail from Outlook into a word document for example, it creates a clickable msg-file. This is the file I'd like to paste into my input.

Right now, I've to copy the mail from Outlook, paste it into word, copy it again, to finally being able to paste the msg-file into the input

HTML:

<div id="documentUploadDiv">
  <div id="filedataholder" filebase64data="" hasfile="false"></div>
  <div id="filereaderdialog_filegroup">
    <input type="file" id="filedatareader_filegroup">
  </div>
</div>

Script:

window.addEventListener('paste', e => {
try{          
    $('#filedatareader_filegroup').get(0).files = e.clipboardData.files;
    $('#filedatareader_filegroup').trigger("change");

    var reader = new FileReader();
    reader.readAsDataURL(e.clipboardData.files[0]);

    $("#filedataholder").attr("filebase64data", reader.result) 
  
    }catch(e){
        console.error(e)
    }
});
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Soerman
  • 184
  • 8
  • Do you develop a web application? Where do you need to grab the data? – Eugene Astafiev Mar 21 '22 at 19:14
  • Yeah it's a web application. In the outlook inbox you can right click on a mail to copy it. Pasting that clipboard into a word document or to a directory/filepath, will create a msg-file. Pasting the clipboard into an html input (type=file) will not :( – Soerman Mar 22 '22 at 12:34

1 Answers1

0

That is because Outlook copies its message in multiple clipboard formats, but FileContents/Filename are not available since there is no real file on the file system.

See Upload fails when user drags and drops attachment from email client for a similar issue.

enter image description here

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78