Example usage for org.apache.poi.hsmf.datatypes Chunks getDisplayFromChunk

List of usage examples for org.apache.poi.hsmf.datatypes Chunks getDisplayFromChunk

Introduction

In this page you can find the example usage for org.apache.poi.hsmf.datatypes Chunks getDisplayFromChunk.

Prototype

public StringChunk getDisplayFromChunk() 

Source Link

Usage

From source file:org.silverpeas.core.mail.extractor.MSGExtractor.java

License:Open Source License

@Override
public Mail getMail() throws MailException {
    try {//  ww  w .  j  a v  a 2  s.  c o m
        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);
    }
}