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));
}
Aggregations