Search in sources :

Example 16 with NoSuchProviderException

use of javax.mail.NoSuchProviderException in project opennms by OpenNMS.

the class JavaReadMailer method retrieveMessages.

/**
     * <p>retrieveMessages</p>
     *
     * @return a {@link java.util.List} object.
     * @throws org.opennms.javamail.JavaMailerException if any.
     */
public List<Message> retrieveMessages() throws JavaMailerException {
    Message[] msgs;
    Folder mailFolder = null;
    final ReadmailHost readmailHost = getReadmailHost(m_config);
    final UserAuth userAuth = getUserAuth(m_config);
    try {
        m_store = m_session.getStore(readmailHost.getReadmailProtocol().getTransport());
        m_store.connect(readmailHost.getHost(), (int) readmailHost.getPort(), userAuth.getUserName(), userAuth.getPassword());
        mailFolder = m_store.getFolder(m_config.getMailFolder());
        mailFolder.open(Folder.READ_WRITE);
        msgs = mailFolder.getMessages();
    } catch (NoSuchProviderException e) {
        throw new JavaMailerException("No provider matching:" + readmailHost.getReadmailProtocol().getTransport() + " from config:" + m_config.getName(), e);
    } catch (MessagingException e) {
        throw new JavaMailerException("Problem reading messages from configured mail store", e);
    }
    return new ArrayList<Message>(Arrays.asList(msgs));
}
Also used : Message(javax.mail.Message) MessagingException(javax.mail.MessagingException) ArrayList(java.util.ArrayList) ReadmailHost(org.opennms.netmgt.config.javamail.ReadmailHost) Folder(javax.mail.Folder) UserAuth(org.opennms.netmgt.config.javamail.UserAuth) NoSuchProviderException(javax.mail.NoSuchProviderException)

Aggregations

NoSuchProviderException (javax.mail.NoSuchProviderException)16 Session (javax.mail.Session)10 MessagingException (javax.mail.MessagingException)9 Store (javax.mail.Store)7 Properties (java.util.Properties)6 Folder (javax.mail.Folder)5 Message (javax.mail.Message)5 Transport (javax.mail.Transport)5 UserAuth (org.opennms.netmgt.config.javamail.UserAuth)3 IOException (java.io.IOException)2 ReadmailHost (org.opennms.netmgt.config.javamail.ReadmailHost)2 ActionException (com.axway.ats.action.model.ActionException)1 RbvStorageException (com.axway.ats.rbv.model.RbvStorageException)1 POP3SSLStore (com.sun.mail.pop3.POP3SSLStore)1 BufferedReader (java.io.BufferedReader)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStreamReader (java.io.InputStreamReader)1 PrintStream (java.io.PrintStream)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1