public MessagesWrapper print() throws MessagingException { logger.info("Found message(s) : " + messages.size()); for (Message message : messages) { logger.info(">>>>>>"); logger.info("Date : " + message.getSentDate()); logger.info("From : " + (message.getFrom().length > 0 ? message.getFrom()[0] : null)); logger.info("Subject : " + message.getSubject()); logger.info("<<<<<<"); } return this; }
public CustomProperties getMessageProperties(Message message, String prefix, CustomProperties p) throws MessagingException, IOException { CustomProperties envVars = new CustomProperties(); String msgSubject = stringify(message.getSubject()); envVars.put(prefix + "subject", msgSubject); envVars.put(prefix + "from", stringify(message.getFrom())); envVars.put(prefix + "replyTo", stringify(message.getReplyTo())); envVars.put(prefix + "flags", stringify(message.getFlags())); envVars.put(prefix + "folder", stringify(message.getFolder())); envVars.put(prefix + "messageNumber", stringify(message.getMessageNumber())); envVars.put(prefix + "receivedDate", stringify(message.getReceivedDate())); envVars.put(prefix + "sentDate", stringify(message.getSentDate())); envVars.put(prefix + "headers", stringify(message.getAllHeaders())); envVars.put(prefix + "content", stringify(message)); envVars.put(prefix + "contentType", stringify(message.getContentType())); envVars.put(prefix + "recipients", stringify(message.getAllRecipients())); // add parameters from email content final CustomProperties properties = CustomProperties.read(getText(message)); envVars.putAll(properties); // envVars.put(prefix + "emailParams", stringify(properties.getMap(), "=", "&")); // add "jobTrigger" if (p.has(subjectContains)) { String subject = p.get(subjectContains); // normalise strings, find index, then get text after it int idx = msgSubject.toLowerCase().indexOf(subject.toLowerCase()); int beginIndex = idx + subject.length(); if (idx > -1 && beginIndex < msgSubject.length()) { envVars.put(prefix + "jobTrigger", msgSubject.substring(beginIndex).trim()); } } return envVars; }