Problems reading excel attachments with javamail
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   maaz_contractor
Posted On:   Friday, October 27, 2006 08:21 PM

Hi, I need to read mails from my pop mailbox which have Excel attachments on a linux box. I am currently identifying the message type with attachment from the message disposition and am copying the file on my local disk. However, when I try to open the the file in excel, I can only see junk characters. Also, the file size of the attachments, one fetched from my java program with javamail and other downloaded from thunderbird email client are different. I have checked both the files in Hex editor shed and they seem to be very very different. I am using the same code as here http://www.jguru.com/faq/view.jsp?EID=26996 to read and downlo   More>>

Hi,


I need to read mails from my pop mailbox which have Excel attachments on a linux box. I am currently identifying the message type with attachment from the message disposition and am copying the file on my local disk. However, when I try to open the the file in excel, I can only see junk characters.



Also, the file size of the attachments, one fetched from my java program with javamail and other downloaded from thunderbird email client are different.




I have checked both the files in Hex editor shed and they seem to be very very different.

I am using the same code as
here



http://www.jguru.com/faq/view.jsp?EID=26996

to read and download the files.

I am also checking if the message is base64 encoded and passing out that input stream.


			
				
private java.io.InputStream getDecodedStream(javax.mail.internet.MimeBodyPart bodyPart) throws Exception{
System.out.println("Encoding: " + bodyPart.getEncoding());
if(bodyPart.getEncoding().equals("base64")){
return javax.mail.internet.MimeUtility.decode(bodyPart.getInputStream(), "base64");
}
return bodyPart.getInputStream();
}







Any help is highly appreciated.



~Maaz    <<Less

Re: Problems reading excel attachments with javamail

Posted By:   Anonymous  
Posted On:   Friday, November 3, 2006 12:03 AM

try to set the
system properties for base64 as ignored and when you are using the mail.jar update it to the new mail.jar.I think there was some problem in the java mail1.3
try to use

System.setProperty("mail.mime.base64.ignoreerrors", "true");

String[] encoding=message.getHeader("Content-Transfer-Encoding");
for(int k = 0; k
if(encoding!=null && encoding.length>0) in1=MimeUtility.decode(bodyPart.getInputStream(),encoding[0]);
About | Sitemap | Contact