7 Replies Latest reply on Feb 28, 2012 9:53 PM by Bill Shannon-Oracle

    Unable to retrieve signed mail message contents from MS outlook 2007 server

      Hi All,

      I am trying to read mail message contents from MS outlook 2007 server using IMAP protocol from my program.

      But we encountering the following exceptions when we are trying to read the message contents which were sent which were signed (SSL certified)
      javax.mail.MessagingException: Unable to load BODYSTRUCTURE
            at com.sun.mail.imap.IMAPMessage.loadBODYSTRUCTURE(IMAPMessage.java:1297)
            at com.sun.mail.imap.IMAPMessage.getDataHandler(IMAPMessage.java:623)
            at javax.mail.internet.MimeMessage.getContent(MimeMessage.java:1419)
      The very same program was used to retrieve the message contents from MS outlook 2003 server before. Both signed and unsigned messages were read without any issues.
      public static void main(String[] args) {
                // TODO Auto-generated method stub
                final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
                Properties props = new Properties();
                props.setProperty("mail.imap.port", "993");
                props.setProperty("mail.store.protocol", "imap");
                props.setProperty( "mail.imap.socketFactory.class", SSL_FACTORY);
                props.setProperty( "mail.imap.socketFactory.fallback", "false");
                try {
                     Session session = Session.getDefaultInstance(props, null);
                     Store store = session.getStore("imap");
                     store.connect("xxxxx.com", "username", "password");
                     Folder folder = store.getFolder("Inbox");
                     Message[] messages = folder.getMessages();
                     for (Message message : messages) {
                          ArrayList<String> fromList = new ArrayList<String>();
                          try {
                               for (Address address : message.getFrom()) {
                                    System.out.println("Mail message from: " + address.toString());
                               System.out.println("Content "+message.getContent());
                          } catch (Exception e) {
                }catch (NoSuchProviderException e) {
                } catch (MessagingException e) {
      V. Arvind

      Edited by: 917126 on Feb 27, 2012 4:46 AM

      Edited by: 917126 on Feb 27, 2012 6:40 AM