2008/02/13 15:32

[imap]Unable to load BODYSTRUCTURE Java

http://java.sun.com/products/javamail/FAQ.html



Q:
I can read messages from my IMAP server with other mail clients, but even though I can connect to the server using JavaMail, when I use JavaMail to read some messages it fails. Doesn't that mean there's a bug in JavaMail?
[new!]
A: No, not usually. Most other mail clients make very little use of the rich IMAP protocol. They use the IMAP protocol as little more than a variant of the POP3 protocol, typically downloading the entire message to the client and parsing it in the client. This allows them to avoid all sorts of parsing and protocol bugs in many IMAP servers, but of course it comes at the cost of being less efficient because they don't take advantage of the IMAP protocol's ability to fetch only the parts of the message that are needed. These server bugs often manifest themselves as the following exception on the client: javax.mail.MessagingException: Unable to load BODYSTRUCTURE

The best approach when running into server bugs of this sort is to contact the vendor of the server and get them to fix their product. Contact javamail@sun.com and we'll help you pinpoint the problem so that you can report it to the server vendor. If you can't get a fix from the server vendor, the following technique will often allow you to work around these server bugs: 


    // Get the message object from the folder in the
    // usual way, for example:
    MimeMessage msg = (MimeMessage)folder.getMessage(n);

    // Use the MimeMessage copy constructor to make a copy
    // of the entire message, which will fetch the entire
    // message from the server and parse it on the client:
    MimeMessage cmsg = new MimeMessage(msg);

    // The cmsg object is disconnected from the server so
    // setFlags will have no effect (for example).  Use
    // the original msg object for such operations.  Use
    // the cmsg object to access the content of the message.



트랙백

이 글과 관련된 글 쓰기 (트랙백 보내기)
TrackbackURL : http://ilovejava.egloos.com/tb/1411544 [도움말]

덧글

덧글 입력 영역

라이프로그