httpGetAsync for msg display from Server


#1

Hi,

Just found this forum… had asked this question at: http://stackoverflow.com/questions/41771696/how-can-i-request-msg-file-from-server-for-reader but haven’t figured it out yet.

I can’t seem to pass the “file path” to the reader script. It runs, no errors, but no msg displays either.
Thanks in advance for any help on this…
Randall


#2

Just very quickly browsing and seeing NS_ERROR_UNKNOWN_PROTOCOL and q:\..., it might help to use the file:// protocol to reference your file instead. This is like http:// but is used to reference local files.

https://msdn.microsoft.com/en-us/library/aa767731(v=vs.85).aspx


#3

Thank you Senocular, I’ll give that a try. The thing is… I’m stuck on how to plug the .msg path into src-file below. This script works to pull up a .msg from the local machine using a Browse button. I basically need to eliminate the Browse button (easy) and plug a selected value into src-file. That’s where I’m stuck.

     $(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();
}

});


#4

I was too hasty with the reply!