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...
-
Http requests can be made using relative paths. They don't need to be visible to the world.isherwood– isherwood2017年01月20日 20:23:56 +00:00Commented Jan 20, 2017 at 20:23
-
Thank you, I'm trying that... it seems to me that the Browse Button is passing a file value through .src-file How can I push the HTTP request value to .src-file so I can read a file off the server instead of the local machine?user4450672– user44506722017年02月09日 15:43:05 +00:00Commented Feb 9, 2017 at 15:43
-
I'm eliminating the Browse button entirely. I'm not trying to push a value into this.files[0] I'm suggesting to pick up the file using httpGetAsync from a line item click and assign it to selectedFile in the email reader script.user4450672– user44506722017年04月07日 15:22:38 +00:00Commented Apr 7, 2017 at 15:22
-
The concept is similar to the following post stackoverflow.com/questions/32427394/… answered by aimme. I'm trying to pass the path value to the server with a link instead of using a browse button to find it on the local machine. The files are on the server which makes sense to use an HTTP request to bring it to the client machine and render it with a javascript email reader script. The reader script works fine... if I could use it to read emails from the server instead of the client machine.user4450672– user44506722017年06月20日 18:54:41 +00:00Commented Jun 20, 2017 at 18:54