Exception while retrieving a message's contents.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Peter_Lindquist
Posted On:   Tuesday, January 28, 2003 12:13 PM

I have a program that handles most incoming mails just fine. A standard email from Excite, however, causes it to blow up. The relevant snippets of code are very simple, when distilled they are: Message[] messages = folder_.getMessages(); MimeMessage m = (MimeMessage)messages[i]; Object content = ((javax.mail.Part) m).getContent(); Most mails work flawlessly. On an email from Excite I get the exception: java.lang.NullPointerException at javax.activation.DataHandler.getBaseType(DataHandler.java:648) at javax.activation.DataHandler.getDataContentHandler(DataHandler.java:605) at javax.activation.DataHandler.getContent(DataHandler.ja   More>>

I have a program that handles most incoming mails just fine. A standard email from Excite, however, causes it to blow up.


The relevant snippets of code are very simple, when distilled they are:


			Message[] messages = folder_.getMessages();
			
MimeMessage m = (MimeMessage)messages[i];
Object content = ((javax.mail.Part) m).getContent();


Most mails work flawlessly. On an email from Excite I get the exception:


			java.lang.NullPointerException
			
at javax.activation.DataHandler.getBaseType(DataHandler.java:648)
at javax.activation.DataHandler.getDataContentHandler(DataHandler.java:605)
at javax.activation.DataHandler.getContent(DataHandler.java:540)
at javax.mail.internet.MimeMessage.getContent(MimeMessage.java:1259)


There are two readily identifiable differences between an incoming Excite mail and one from Outlook. They are the encoding values identified here:


Outlook:
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


Excite:
charset="us-ascii"
Content-Transfer-Encoding: 7bit



When I query the incoming message object with some debug code-- I can see all the headers just fine, I can retrieve the subject, I can retrieve the encoding string ("7bit"), but the line count says the message has '-1' lines in it, and any attempt to retrieve the content results in the NullPointerException.


If anyone has any ideas at all, I'd be very grateful. If you need more info, please just post and I'll fill in the details.


Thank you!

   <<Less

Re: Exception while retrieving a message's contents.

Posted By:   John_Zukowski  
Posted On:   Friday, January 31, 2003 08:39 PM

Use getRawInputStream() when you can't figure out why an exception is happening. You'll need to parse everything manually... but its better than nothing.
About | Sitemap | Contact