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.setOutboundProperty(name, value);
}
Object listPropertyValue = muleMessage.getOutboundProperty(listName);
if (null == listPropertyValue)
{
listPropertyValue = new LinkedList<Object>();
muleMessage.setOutboundProperty(listName, listPropertyValue);
}
if (listPropertyValue instanceof List<?>)
{
((List) listPropertyValue).add(header.getValue());
}
}
}