Example usage for javax.mail MessagingException getMessage

List of usage examples for javax.mail MessagingException getMessage

Introduction

In this page you can find the example usage for javax.mail MessagingException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.cubusmail.mail.imap.IMAPMailFolder.java

public Message[] retrieveMessages(String sortfield) {

    Message[] msgs = EMPTY_MESSAGE_ARRAY;
    if (this.folder != null) {
        try {//  w  w  w.j a  v  a2 s.  c o  m
            if (!this.folder.isOpen()) {
                this.folder.open(Folder.READ_WRITE);
            }

            long time = System.currentTimeMillis();
            logger.debug("Start getting messages...");
            msgs = folder.getMessages();
            logger.debug(
                    "Millis for getting " + msgs.length + " messages: " + (System.currentTimeMillis() - time));
            time = System.currentTimeMillis();
            FetchProfile fp = MessageUtils.createFetchProfile(false, sortfield);

            logger.debug("Start fetching messages...");
            folder.fetch(msgs, fp);
            logger.debug(
                    "Millis for fetching " + msgs.length + " Messages: " + (System.currentTimeMillis() - time));

        } catch (MessagingException e) {
            logger.error(e.getMessage(), e);
        }
    }

    return msgs;
}

From source file:com.cubusmail.server.mail.imap.IMAPMailFolder.java

public int getUnreadMessageCount() {

    try {//from   ww  w.j  av a  2 s .com
        return this.folder.getUnreadMessageCount();
    } catch (MessagingException ex) {
        log.error(ex.getMessage(), ex);
        return 0;
    }
}

From source file:de.teamgrit.grit.entities.Exercise.java

/**
 * Notifies the administrator that the exercise has finished processing and
 * the report is ready for download./*from   ww  w  .  jav a  2 s.  co  m*/
 */
private void notifyAdmin() {
    try {
        SendMailSSL.sendMail(GenerateMailObjectHelper.generateMailObjectNotifyAdmin(context, id));
    } catch (MessagingException e) {
        LOGGER.severe("Exception occured while trying to send mails to " + "admin. " + e.getMessage());
    }
}

From source file:org.openadaptor.auxil.connector.mail.MailReadConnector.java

/**
 * Opens the inbox as defined by the Folder property
 *
 * @throws ConnectionException if there was a problem which is just a wrapper around
 * the underlying MessagingException//from www . j a v a 2s. co  m
 */
private void openInbox() {
    try {
        inbox = conn.openFolder(folder, createFolder);
    } catch (MessagingException e) {
        throw new ConnectionException("Failed to open the inbox:" + e.getMessage(), e, this);
    }
}

From source file:org.openadaptor.auxil.connector.mail.MailReadConnector.java

/**
 * Closes the inbox. Will expunge messages if either the [deleteWhenRead] or
 * [moveToFolder] properties are set./*from  w w  w.  j  a  va2  s  . c o m*/
 *
 * @throws ConnectionException if there was a problem which is just a wrapper around
 * the underlying MessagingException
 */
private void closeInbox() {
    try {
        boolean expunge = (deleteWhenRead || moveWhenRead());
        conn.closeFolder(inbox, expunge);
    } catch (MessagingException e) {
        throw new ConnectionException("Failed to close the inbox:" + e.getMessage(), e, this);
    }
}

From source file:com.alvexcore.repo.emails.impl.ExtendedEmailMessage.java

protected void parseMessage(MimeMessage msg, UIDFolder folder) {
    try {//  w  w w  .j  a v a 2s  . c  o  m
        if (uid == -1) {
            uid = folder.getUID(msg);
        }
        if (id == null) {
            id = msg.getMessageID();
        }
        if (inReplyTo == null) {
            String[] headers = msg.getHeader(IN_REPLY_TO);
            if (headers != null) {
                if (headers.length == 1)
                    inReplyTo = headers[0];
                else if (headers.length > 1)
                    throw new EmailMessageException(ERR_EXTRACTING_IN_REPLY_TO,
                            "Not more than one " + IN_REPLY_TO + " header expected");
            }
        }
    } catch (MessagingException e) {
        throw new EmailMessageException(ERR_EXTRACTING_ATTRS, e.getMessage());
    }
}

From source file:com.cubusmail.server.mail.imap.IMAPMailFolder.java

public Message[] retrieveMessages(MessageListFields sortField, boolean ascending,
        MessageListFields[] searchFields, String[] searchValues) {

    Message[] msgs = EMPTY_MESSAGE_ARRAY;
    if (this.folder != null) {
        try {/*from  www .j  a  v a2 s.c om*/
            if (!this.folder.isOpen()) {
                this.folder.open(Folder.READ_WRITE);
            }

            long time = System.currentTimeMillis();
            log.debug("Start getting messages...");
            msgs = folder.getMessages();
            log.debug(
                    "Millis for getting " + msgs.length + " messages: " + (System.currentTimeMillis() - time));
            time = System.currentTimeMillis();
            FetchProfile fp = MessageUtils.createFetchProfile(false, sortField);

            log.debug("Start fetching messages...");
            folder.fetch(msgs, fp);
            log.debug(
                    "Millis for fetching " + msgs.length + " Messages: " + (System.currentTimeMillis() - time));

            if (searchFields != null && searchFields.length > 0 && searchValues != null
                    && searchValues.length > 0) {
                log.debug("Start filtering messages...");
                SearchTerm term = MessageUtils.createSearchTerm(searchFields, searchValues);
                msgs = folder.search(term);
                log.debug("Millis for filtering " + msgs.length + " Messages: "
                        + (System.currentTimeMillis() - time));
            }

            MessageUtils.sortMessages(msgs, sortField, ascending);
        } catch (MessagingException e) {
            log.error(e.getMessage(), e);
        }
    }

    return msgs;
}

From source file:org.openadaptor.auxil.connector.mail.MailReadConnector.java

/**
 * Creates a connection to the remote mail server. Dumps out message reading
 * properties to the log./*from w w  w .j a v a2s  . c o m*/
 *
 * @throws ConnectionException if there was a problem or if the MailConnection
 * properties have not been set
 */
public void connect() {
    log.info("Connecting to mail server");

    if (conn == null)
        throw new ConnectionException("No connection properties set", this);

    try {
        conn.connect();
    } catch (MessagingException e) {
        throw new ConnectionException("Failed to connect to [" + conn.getHost() + "]: " + e.getMessage(), e,
                this);
    }
}

From source file:org.openadaptor.auxil.connector.mail.MailReadConnector.java

/**
 * Disconnects from the mail server/*from  w w  w. j  a  va 2 s  . c  o  m*/
 *
 * @throws ConnectionException if there was a problem
 */
public void disconnect() {
    log.info("Disconnecting from mail server");

    try {
        if (conn != null)
            conn.disconnect();
    } catch (MessagingException e) {
        throw new ConnectionException("Failed to disconnect from [" + conn.getHost() + "]: " + e.getMessage(),
                e, this);
    }
}

From source file:org.mxhero.engine.plugin.attachmentlink.alcommand.internal.domain.Message.java

public boolean hasAttachments() {
    boolean hasAttach = false;
    try {/*from  w  w w . j av  a  2  s  . c  o  m*/
        MimeMessage message = getMail().getMessage();
        hasAttach = hasAttach(message);
    } catch (MessagingException e) {
        log.error("Could not verify if the email has attachments. EmailId: " + getMessagePlatformId() + " - "
                + e.getClass().getName() + " - " + e.getMessage());
        throw new RuntimeException("Could not read mime message");
    } catch (IOException e) {
        log.error("Could not verify if the email has attachments. EmailId: " + getMessagePlatformId() + " - "
                + e.getClass().getName() + " - " + e.getMessage());
        throw new RuntimeException("Could not read mime message");
    }
    return hasAttach;
}