List of usage examples for org.apache.poi.hsmf.datatypes Chunks getEmailFromChunk
public StringChunk getEmailFromChunk()
From source file:org.silverpeas.core.mail.extractor.MSGExtractor.java
License:Open Source License
@Override public Mail getMail() throws MailException { try {/*from w ww . j a v a 2 s .c om*/ Mail mail = new Mail(); setMailDate(mail); setMailSubject(mail); Chunks mainChunks = message.getMainChunks(); InternetAddress from = new InternetAddress(mainChunks.getEmailFromChunk().getValue(), mainChunks.getDisplayFromChunk().getValue()); mail.setFrom(from); String[] toNames = StringUtils.split(message.getDisplayTo(), ';'); mail.setTo(getInChunks(toNames).toArray(new Address[toNames.length])); String[] ccNames = StringUtils.split(message.getDisplayCC(), ';'); List<InternetAddress> ccAddresses = getInChunks(ccNames); if (!ccAddresses.isEmpty()) { mail.setCc(getInChunks(ccNames).toArray(new Address[ccNames.length])); } setMailBody(mail); return mail; } catch (ChunkNotFoundException | ParseException | UnsupportedEncodingException e) { throw new MailException(e); } }