public Folder getInboxFolder ( ) { String strMessageType = MessageTransportModel . EMAIL ; String strClassName = null ; Record recMessageTransport = this . getRecord ( MessageTransportModel . MESSAGE_TRANSPORT_FILE ) ; if ( recMessageTransport == null ) recMessageTransport = Record . makeRecordFromClassName ( MessageTransportModel . THICK_CLASS , this ) ; recMessageTransport . setKeyArea ( MessageTransportModel . CODE_KEY ) ; recMessageTransport . getField ( MessageTransportModel . CODE ) . setString ( strMessageType ) ; Map < String , Object > properties = null ; try { if ( recMessageTransport . seek ( null ) ) { PropertiesField fldProperty = ( PropertiesField ) recMessageTransport . getField ( MessageTransportModel . PROPERTIES ) ; strClassName = fldProperty . getProperty ( MessageTransportModel . TRANSPORT_CLASS_NAME_PARAM ) ; properties = fldProperty . loadProperties ( ) ; this . setProperties ( properties ) ; } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } if ( strClassName == null ) strClassName = EmailMessageTransport . class . getName ( ) ; String strHost = this . getProperty ( POP3_HOST ) ; int iPort = 110 ; if ( this . getProperty ( POP3_PORT ) != null ) iPort = Integer . parseInt ( this . getProperty ( POP3_PORT ) ) ; String strUsername = this . getProperty ( POP3_USERNAME ) ; String strPassword = this . getProperty ( POP3_PASSWORD ) ; strPassword = PasswordPropertiesField . decrypt ( strPassword ) ; String strInbox = this . getProperty ( POP3_INBOX ) ; if ( strInbox == null ) strInbox = DEFAULT_INBOX ; String strInterval = this . getProperty ( POP3_INTERVAL ) ; if ( strInterval == null ) strInterval = DEFAULT_INTERVAL ; try { Properties props = Utility . mapToProperties ( properties ) ; //System.getProperties(); if ( ( props . getProperty ( POP3_SSL ) != null ) && ( props . getProperty ( POP3_SSL ) . equalsIgnoreCase ( DBConstants . TRUE ) ) ) { props . setProperty ( "mail.pop3.socketFactory.class" , SSL_FACTORY ) ; props . setProperty ( "mail.pop3.socketFactory.fallback" , "false" ) ; if ( this . getProperty ( POP3_PORT ) != null ) if ( this . getProperty ( "mail.pop3.socketFactory.port" ) == null ) props . setProperty ( "mail.pop3.socketFactory.port" , this . getProperty ( POP3_PORT ) ) ; } // Get a Session object Session session = Session . getDefaultInstance ( props , null ) ; session . setDebug ( true ) ; // Get a Store object URLName url = new URLName ( STORE_TYPE , strHost , iPort , "" , strUsername , strPassword ) ; // Store store = session.getStore("imap"); Store store = session . getStore ( url ) ; // Connect store . connect ( ) ; // Open a Folder Folder folder = store . getFolder ( strInbox ) ; if ( folder == null || ! folder . exists ( ) ) { Utility . getLogger ( ) . warning ( "Invalid folder" ) ; System . exit ( 1 ) ; } folder . open ( Folder . READ_WRITE ) ; // Check mail once in "freq" MILLIseconds //? int freq = Integer.parseInt(strInterval); return folder ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } return null ; }
Open the poop3 inbox .