5

Hi i have implemented drag and drop outlook emails and files in to sales force.If we drag some file it will store that file into attachment object similarly if we drag some .msg file i.e outlook email it will store into attachment object.To display file content i am using following code as:

<a href="#" onClick='window.open("https://c.na15.visual.force.com/servlet/servlet.FileDownload?file='attachmentid'","Ratting","width=850,height=600,left=150,top=90,toolbar=1,status=1,");'> 
                                                    </a> 

In above code if we pass attcahment id of file it will display content of file but if it is .msg file it is downloading file rather than showing content.Is there any way to directly display content of .msg file rather than downloading. Even how we can parse .msg file in java Script.

2

You would have to parse the file first. You can do this in JavaScript (it would be non-trivial, but possible), and you can probably accomplish this in Apex Code in the next release (due to the removal of the 200,000 line limit in exchange for a CPU time limit). Some browsers may choose to embed the content (e.g. run an instance of the mail agent inside the browser), but you cannot force this as a developer. You might try using the embed tag, but this is highly dependent on the OS and browser.

  • 1
    Any tips or links or example how we can parse .msg file in JavaScript? – Jayant Jadhav Sep 3 '13 at 5:52
  • 1
    If you don't mind excluding <IE10, then you can just use a TypedArray to parse the file. CFB (Compound File Binary) is basically a disc-in-a-file, complete with FAT (File Allocation Table), directories, etc. I've looked into this before on the forums (developer.force.com), but I didn't have time then to write a full working code demo. I'll see what I can do this time around. – sfdcfox Sep 4 '13 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.