# httpGetAsync for msg display from Server

**URL:** https://forum.kirupa.com/t/httpgetasync-for-msg-display-from-server/636364
**Category:** programming
**Created:** [April 3, 2017, 8:20pm UTC](https://forum.kirupa.com/t/httpgetasync-for-msg-display-from-server/636364 "2017-04-03T20:20:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![gnuTwist](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/gnutwist/32/8344_2.png) [@gnuTwist](https://forum.kirupa.com/u/gnuTwist)
#### Post date: [April 3, 2017, 8:20pm UTC](https://forum.kirupa.com/t/httpgetasync-for-msg-display-from-server/636364/1 "2017-04-03T20:20:17Z")

</div>

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](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

---

<div class="post-metadata">

### Author: ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)
#### Post date: [April 3, 2017, 8:44pm UTC](https://forum.kirupa.com/t/httpgetasync-for-msg-display-from-server/636364/2 "2017-04-03T20:44:54Z")

</div>

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](https://msdn.microsoft.com/en-us/library/aa767731(v=vs.85).aspx)

---

<div class="post-metadata">

### Author: ![gnuTwist](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/gnutwist/32/8344_2.png) [@gnuTwist](https://forum.kirupa.com/u/gnuTwist)
#### Post date: [April 4, 2017, 12:37pm UTC](https://forum.kirupa.com/t/httpgetasync-for-msg-display-from-server/636364/3 "2017-04-04T12:37:36Z")

</div>

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

```

});

---

<div class="post-metadata">

### Author: ![tryangle](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@tryangle](https://forum.kirupa.com/u/tryangle)
#### Post date: [April 7, 2017, 2:11pm UTC](https://forum.kirupa.com/t/httpgetasync-for-msg-display-from-server/636364/4 "2017-04-07T14:11:06Z")

</div>

I was too hasty with the reply!
