This has to be possible... I found something similar for use with audio tracks: Feed File Reader from Server and this one also: Reading Server Side Files but I can't seem to put the pieces together to make it work!
Also, my votes don't count because I don't have enough reputation points, but someone needs to upvote Philip for providing the answer to his own question more than a year ago to: Feed File Reader from Server! I wish I could figure out how to modify it for a msg reader.
The lower script (and a few supporting scripts) reads an msg file without opening Outlook... it works Client side with a Browse button, which is of no use because the msg files are on the Server. I've got xmlHTTPRequest working but I get a 404 page when I try to display .msg file. The file is there, because I can change the extension to .txt and it will display jibberish... (maybe I'm there, and it just needs to be plugged into the reader script somewhere?) Besides that, I thought if I used overrideMimType it would help, but it displays [object blob].
xhr.overrideMimeType('text\/plain; charset=x-user-defined');
How do I pick up the file and attribute the src-file class to it? (Thinking that's how it gets interpreted by the script below.)
$(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();
}
});
Thanks in advance for any help on this...