从 Outlook 复制邮件并将 msg-file 粘贴到文件输入
将不同的文件复制到输入中,例如 xlxs、png、msg 等,效果非常好。 我希望实现的是能够将邮件直接从 Outlook 复制到输入(作为消息文件)。
问题:
如果我使用当前解决方案从 Outlook 复制邮件,我会得到模糊的信息,例如主题、发送日期、收件人等 - 就像将剪贴板粘贴到记事本中一样。
目标:
例如,如果您将 Outlook 中的邮件复制到 Word 文档中,则会创建一个可单击的消息文件。这是我想要粘贴到我的输入中的文件。
现在,我必须从 Outlook 复制邮件,将其粘贴到 word 中,再次复制,最后才能将 msg 文件粘贴到输入中
HTML:
<div id="documentUploadDiv">
<div id="filedataholder" filebase64data="" hasfile="false"></div>
<div id="filereaderdialog_filegroup">
<input type="file" id="filedatareader_filegroup">
</div>
</div>
脚本:
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)
}
});
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)
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为 Outlook 以多种剪贴板格式复制其邮件,但文件内容/文件名不可用,因为文件系统上没有真正的文件。
请参阅用户拖动时上传失败并从电子邮件客户端删除附件以解决类似问题。
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.