Getting image attachments in JTextPane
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rajiv_M
Posted On:   Friday, May 11, 2001 11:24 PM

Using JavaMail1.2 i was able to send images as attachments,but when i try to retrieve them i get an error.I send the images as FileDataSource object to a multipart message.It worked. I then tried to read a multipart message and tried to display mime type "image/..." in a JTextPane. But when i tried to read the mail and use a similar FileDataSource object,as i used to send i get a Class Cast Exception: java.lang.ClassCastException: javax.mail.internet.MimePartDataSource at JavaMailer.listParts(JavaMailer.java:692) at JavaMailer.checkMime(JavaMailer.java:664) at JavaMailer.readMail(JavaMailer.java:624) at JavaMailer$7.mouseClicked(JavaMailer.java:249) at ...... When i changed the File   More>>

Using JavaMail1.2 i was able to send images as attachments,but when i try to retrieve them i get an error.I send the images as FileDataSource object to a multipart message.It worked.
I then tried to read a multipart message and tried to display mime type "image/..." in a JTextPane.
But when i tried to read the mail and use a similar FileDataSource object,as i used to send i get a Class Cast Exception:

java.lang.ClassCastException: javax.mail.internet.MimePartDataSource at JavaMailer.listParts(JavaMailer.java:692)
at JavaMailer.checkMime(JavaMailer.java:664)
at JavaMailer.readMail(JavaMailer.java:624)
at JavaMailer$7.mouseClicked(JavaMailer.java:249)
at ......

When i changed the FileDataSource to MimePartDataSource, the getName() method returns null, thereby JTextPane showing blank.
i read in JavaMail API1.2 that getName() returns nothing for MimePartDataSource implementation.

Then, how can i get the filename of the "image/..." part of a multipart
message?

   <<Less
About | Sitemap | Contact