这必须是可能的......我发现类似的东西用于音轨:Feed File Reader from Server而且这个也是:Reading Server Side Files但是我似乎无法把它们放在一起制作它工作!
另外,我的投票不算数,因为我没有足够的声望点,但有人需要upvote Philip for providing the answer to his own question more than a year ago to: Feed File Reader from Server!我希望我能弄清楚如何为msg阅读器修改它。
较低的脚本(以及一些支持脚本)在不打开Outlook的情况下读取msg文件...它在客户端使用“浏览”按钮,这是没用的,因为msg文件在服务器上。我有xmlHTTPRequest工作,但当我尝试显示.msg文件时,我得到一个404页面。该文件在那里,因为我可以将扩展名更改为.txt并且它将显示乱码...(也许我在那里,它只需要插入到某处的读者脚本中?)除此之外,我想如果我使用overrideMimType它会有所帮助,但它会显示[object blob]。
xhr.overrideMimeType('text\/plain; charset=x-user-defined');
如何获取文件并将src-file类归属于它? (想一想下面的脚本如何解释它。)
$(function () {
if (isSupportedFileAPI()) {
$('.src-file').change(function () {
var selectedFile = this.files[0];
if (!selectedFile) {
$('.msg-info, .incorrect-type').hide();
return;
}
if (selectedFile.name.indexOf('.msg') == -1) {
$('.msg-info').hide();
$('.incorrect-type').show();
return;
}
$('.msg-example .msg-file-name').html(selectedFile.name);
$('.incorrect-type').hide();
// read file...
var fileReader = new FileReader();
fileReader.onload = function (evt) {
var buffer = evt.target.result;
var msgReader = new MSGReader(buffer);
var fileData = msgReader.getFileData();
if (!fileData.error) {
$('.msg-example .msg-from').html(formatEmail({name: fileData.senderName, email: fileData.senderEmail}));
$('.msg-example .msg-to').html(jQuery.map(fileData.recipients, function (recipient, i) {
return formatEmail(recipient);
}).join('<br/>'));
$('.msg-example .msg-subject').html(fileData.subject);
$('.msg-example .msg-body').html(fileData.body ? fileData.body.substring(0, Math.min(500, fileData.body.length)) + (fileData.body.length > 500 ? '...' : '') : '');
$('.msg-example .msg-attachment').html(jQuery.map(fileData.attachments, function (attachment, i) {
return attachment.fileName + ' [' + attachment.contentLength + 'bytes]' + (attachment.pidContentId ? '; ID = ' + attachment.pidContentId : '');
}).join('<br/>'));
$('.msg-info').show();
// Use msgReader.getAttachment to access attachment content ...
// msgReader.getAttachment(0) or msgReader.getAttachment(fileData.attachments[0])
} else {
$('.msg-info').hide();
$('.incorrect-type').show();
}
};
fileReader.readAsArrayBuffer(selectedFile);
});
} else {
$('.msg-example').hide();
$('.file-api-not-available').show();
}
});
提前感谢您对此的任何帮助...