Note that there are some explanatory texts on larger screens.

plurals
  1. POError reading .msg file downloaded from servlet
    primarykey
    data
    text
    <p>I have written a servlet which reads the outlook .msg file using <a href="http://auxilii.com/msgparser/Page.php?id=18000" rel="nofollow">msgparser</a> and writes the content in ServletOutputStream so that it could be downloaded once the url is hit.</p> <p>Problem which i am facing is, that file reports an error when i try to open that downloaded file in outlook.</p> <p>Error says : <strong>Cannot open the file as it may not exists or you may not have permission to access file......</strong></p> <p>Even if the file is in right format (.msg), then too there is such error. I am sure I am doing something wrong while parsing. Please suggest. Below is the servlet code :</p> <pre><code>MsgParser msgp = new MsgParser(); Message msg = msgp.parseMsg("D:\\Demo.msg"); String str1=msg.toString(); byte[] b=str1.getBytes();// here b is byte array //The below code is to open show the pop up so that user can save the msg file.. response.setContentType("application/vnd.ms-outlook"+" ;charset=utf-8"); response.setHeader("Content-Disposition","attachment;filename=" + "Demo.msg"); ServletOutputStream servletOutputStream = response.getOutputStream(); DataOutput dataOutput = new DataOutputStream(servletOutputStream); if (b!= null) { response.setContentLength(b.length); for (int i = 0; i &lt; b.length; i++) { dataOutput.writeByte(b[i]); } } if (servletOutputStream != null) { servletOutputStream.flush(); servletOutputStream.close(); } PrintWriter pw = response.getWriter(); pw.println(dataOutput); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload