use of javax.mail.internet.AddressException in project stanbol by apache.
the class SimpleMailExtractor method extract.
public void extract(URI id, InputStream stream, Charset charset, String mimeType, RDFContainer result) throws ExtractorException {
try {
// parse the stream
MimeMessage message = new MimeMessage(null, stream);
result.add(RDF.type, NMO.Email);
// extract the full-text
StringBuilder buffer = new StringBuilder(10000);
processMessage(message, buffer, result);
String text = buffer.toString().trim();
if (text.length() > 0) {
result.add(NMO.plainTextMessageContent, text);
result.add(NIE.plainTextContent, text);
}
// extract other metadata
String title = message.getSubject();
if (title != null) {
title = title.trim();
if (title.length() > 0) {
result.add(NMO.messageSubject, title);
}
}
try {
copyAddress(message.getFrom(), NMO.from, result);
} catch (AddressException e) {
// ignore
}
copyAddress(getRecipients(message, RecipientType.TO), NMO.to, result);
copyAddress(getRecipients(message, RecipientType.CC), NMO.cc, result);
copyAddress(getRecipients(message, RecipientType.BCC), NMO.bcc, result);
MailUtil.getDates(message, result);
} catch (MessagingException e) {
throw new ExtractorException(e);
} catch (IOException e) {
throw new ExtractorException(e);
}
}
Aggregations