List of usage examples for javax.mail Message getAllHeaders
public Enumeration<Header> getAllHeaders() throws MessagingException;
From source file:org.mule.transport.email.MailMuleMessageFactory.java
@SuppressWarnings({ "unchecked", "rawtypes" }) protected void addMailHeadersToMessageProperties(Message mailMessage, DefaultMuleMessage muleMessage) throws MessagingException { for (Enumeration<?> e = mailMessage.getAllHeaders(); e.hasMoreElements();) { Header header = (Header) e.nextElement(); String name = header.getName(); String listName = MailUtils.toListHeader(name); String value = header.getValue(); if (null == muleMessage.getOutboundProperty(name)) { muleMessage.setInboundProperty(name, value); }//w w w . j a v a2 s. co m Object listPropertyValue = muleMessage.getOutboundProperty(listName); if (null == listPropertyValue) { listPropertyValue = new LinkedList<Object>(); muleMessage.setInboundProperty(listName, listPropertyValue); } if (listPropertyValue instanceof List<?>) { ((List) listPropertyValue).add(header.getValue()); } } }
From source file:org.socraticgrid.displaymaildata.DisplayMailDataHandler.java
/** * Prints all header attributes in a Msg * @param msgs/* w w w .j ava 2 s. c om*/ */ void printEmailMsg(Message msg) throws MessagingException { Enumeration headers = msg.getAllHeaders(); while (headers.hasMoreElements()) { Header h = (Header) headers.nextElement(); System.out.println(h.getName() + ": " + h.getValue()); } }