public Email parse(Resource resource) {
EmailContentHandler handler = new EmailContentHandler();
try {
SAXParserFactory.newInstance().newSAXParser().parse(resource.getInputStream(), handler);
} catch (ParserConfigurationException pce) {
throw new EmailParseException("Could not parse email resource '" + resource.getDescription() + "'", pce);
} catch (SAXException se) {
throw new EmailParseException("Could not parse email resource '" + resource.getDescription() + "'", se);
} catch (IOException ioe) {
throw new EmailParseException("Could not parse email resource '" + resource.getDescription() + "'", ioe);
}
return handler.getEmail();
}