Package javax.mail

Examples of javax.mail.Message


        try {
            if (StringUtils.isEmpty(plaintext)) {
                throw new CedarRuntimeException("Must provide plaintext body.");
            }

            Message message = createBasicMessage(sender, recipients, replyTo, subject);
            message.setText(plaintext);
            return message;
        } catch (CedarRuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new CedarRuntimeException("Failed to create message: " + e.getMessage(), e);
View Full Code Here


            Multipart content = new MimeMultipart("alternative");
            content.addBodyPart(plaintextPart);
            content.addBodyPart(htmlPart);

            Message message = createBasicMessage(sender, recipients, replyTo, subject);
            message.setContent(content);
            return message;
        } catch (CedarRuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new CedarRuntimeException("Failed to create message: " + e.getMessage(), e);
View Full Code Here

        if (StringUtils.isEmpty(subject)) {
            throw new CedarRuntimeException("Must provide subject.");
        }

        Session session = Session.getDefaultInstance(new Properties(), null);
        Message message = new MimeMessage(session);
        message.setFrom(sender);
        message.setSubject(subject);

        for (InternetAddress recipient : recipients) {
            message.addRecipient(Message.RecipientType.TO, recipient);
        }

        if (replyTo != null) {
            message.setReplyTo(new Address[] { replyTo, });
        }

        return message;
    }
View Full Code Here

            MailCommandManager.openFolder(aFolder, Folder.READ_ONLY);

            // add folder, too
            addResult(aFolder);

            Message msg = uidFolder.getMessageByUID(msgUID);
            addResult(msg);
        }
View Full Code Here

            MailCommandManager.openFolder(aFolder, Folder.READ_ONLY);

            // add folder, too
            addResult(aFolder);

            Message msg = aFolder.getMessage(msgId);
            addResult(msg);
        }
View Full Code Here

            // add folder, too
            addResult(aFolder);

            // get the message
            Message msg = aFolder.getMessage(msgId);

            if (msg == null) {
                String message = "Cannot get message for id " + String.valueOf(msgId);
                getLogger().warn(message);
                return;
            }
            try {
                Part part = null;
                Object objRef = msg.getContent();
                if (!(objRef instanceof Multipart)) {
                    String message = "Message of id " + String.valueOf(msgId) + " is not a multipart message!";
                    getLogger().warn(message);
                    return;
                }
View Full Code Here

            // update pending number of exchanges
            pendingExchanges = total - index - 1;

            // must use the original message in case we need to workaround a charset issue when extracting mail content
            final Message mail = exchange.getIn(MailMessage.class).getOriginalMessage();

            // need to call setPeek on java-mail to avoid the message being flagged eagerly as SEEN on the server in case
            // we process the message and rollback due an exception
            if (getEndpoint().getConfiguration().isPeek()) {
                peekMessage(mail);
View Full Code Here

        if (LOG.isDebugEnabled()) {
            LOG.debug("Fetching {} messages. Total {} messages.", count, messages.length);
        }

        for (int i = 0; i < count; i++) {
            Message message = messages[i];

            if (LOG.isTraceEnabled()) {
                LOG.trace("Mail #{} is of type: {} - {}", new Object[]{i, ObjectHelper.classCanonicalName(message), message});
            }

            if (!message.getFlags().contains(Flags.Flag.DELETED)) {
                Exchange exchange = getEndpoint().createExchange(message);
                if (getEndpoint().getConfiguration().isMapMailMessage()) {
                    // ensure the mail message is mapped, which can be ensured by touching the body/header/attachment
                    LOG.trace("Mapping #{} from javax.mail.Message to Camel MailMessage", i);
                    exchange.getIn().getBody();
View Full Code Here

            // If the protocol is POP3, the message needs to be synced with the folder via the UID.
            // Otherwise setting the DELETE/SEEN flag won't delete the message.
            String uid = (String) exchange.removeProperty(POP3_UID);
            if (uid != null) {
                int count = folder.getMessageCount();
                Message found = null;
                LOG.trace("Looking for POP3Message with UID {} from folder with {} mails", uid, count);
                for (int i = 1; i <= count; ++i) {
                    Message msg = folder.getMessage(i);
                    if (uid.equals(generatePop3Uid(msg))) {
                        LOG.debug("Found POP3Message with UID {} from folder with {} mails", uid, count);
                        found = msg;
                        break;
                    }
View Full Code Here

        String text = in.getBody(String.class);
        log.debug("Has headers: " + in.getHeaders());

        MailExchange mailExchange = (MailExchange) exchange;
        Message inMessage = mailExchange.getIn().getMessage();
        assertNotNull("In message has no JavaMail message!", inMessage);
        Enumeration iter = inMessage.getAllHeaders();
        while (iter.hasMoreElements()) {
            Header header = (Header) iter.nextElement();
            String[] value = message.getHeader(header.getName());
            log.debug("Header: " + header.getName() + " has value: " + ObjectHelper.asString(value));
        }
View Full Code Here

TOP

Related Classes of javax.mail.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.