• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading an outlook .msg file stored in server to my servlet  RSS feed

 
kalyan raj
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone, i have been facing one problem while reading an outlook .msg file to my servlet and then opening that file as pop up using servletoutputstream so that user can download that file.The problem is i could get that file using msgparser but after outputting that file i was unable to store it as original outlook file.size of output file is getting reduced , i dont know whether source file in server is encoded or not. can anyone help me out in getting exact server file in the client machine so that client can open it in is outlook..
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most likely there's something wrong with your code. But we can't see it so all we can say is that it's probably wrong. I would suggest you post it.
 
kalyan raj
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly thanks for your reply.. Well below is the code iam using ..

MsgParser msgp = new MsgParser();

Message msg = msgp.parseMsg("c://Testingmail.msg");//some msg file which i have taken from outlook and kept in local disk

String str1=msg.toString();

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=" + "Testingmail.msg");

ServletOutputStream servletOutputStream = response
.getOutputStream();


DataOutput dataOutput = new DataOutputStream(
servletOutputStream);

if (b!= null) {
response.setContentLength(b.length);

for (int i = 0; i < b.length; i++) {
dataOutput.writeByte(b[i]);
}



}
if (servletOutputStream != null) {

servletOutputStream.flush();

servletOutputStream.close();
}



I tried with many combinations while reading the msg file from server path like using bufferreader ... once i save the file , iam getting in msg format but not actual content .. when i say open directly , it is saying error cannot open file or you dont have permission ...... if i drag that downloaded file it is going as attachment of new mail..one thing is for sure.. iam not getting actual content of server file..i think once we say save from outlook it will be stored as encoded file.. we need to decode it..i tried by decoding the file also but invain if you have code to get it please share ...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!