List of usage examples for org.apache.poi.hsmf MAPIMessage getRecipientDetailsChunks
public RecipientChunks[] getRecipientDetailsChunks()
From source file:com.jaeksoft.searchlib.parser.MapiMsgParser.java
License:Open Source License
@Override protected void parseContent(StreamLimiter streamLimiter, LanguageEnum lang) throws IOException, SearchLibException { MAPIMessage msg = new MAPIMessage(streamLimiter.getNewInputStream()); msg.setReturnNullOnMissingChunk(true); ParserResultItem result = getNewParserResultItem(); try {/*from w w w.jav a2 s . c o m*/ result.addField(ParserFieldEnum.email_display_from, msg.getDisplayFrom()); result.addField(ParserFieldEnum.email_display_to, msg.getDisplayTo()); result.addField(ParserFieldEnum.email_display_cc, msg.getDisplayCC()); result.addField(ParserFieldEnum.email_display_bcc, msg.getDisplayBCC()); result.addField(ParserFieldEnum.subject, msg.getSubject()); result.addField(ParserFieldEnum.htmlSource, msg.getHtmlBody()); result.addField(ParserFieldEnum.content, msg.getTextBody()); result.addField(ParserFieldEnum.creation_date, msg.getMessageDate()); result.addField(ParserFieldEnum.email_conversation_topic, msg.getConversationTopic()); RecipientChunks[] recipientChuncksList = msg.getRecipientDetailsChunks(); if (recipientChuncksList != null) { for (RecipientChunks recipientChunks : recipientChuncksList) { result.addField(ParserFieldEnum.email_recipient_name, recipientChunks.getRecipientName()); result.addField(ParserFieldEnum.email_recipient_address, recipientChunks.getRecipientEmailAddress()); } } if (StringUtils.isEmpty(msg.getHtmlBody())) result.langDetection(10000, ParserFieldEnum.content); else result.langDetection(10000, ParserFieldEnum.htmlSource); } catch (ChunkNotFoundException e) { Logging.warn(e); } }
From source file:org.silverpeas.core.mail.MsgMailExtractorIntegrationTest.java
License:Open Source License
/** * This unit test is support for MSG exploration solution testing. * * @throws Exception//ww w. ja va2s . c om */ @Test public void readMailWithAttachmentsMSG() throws Exception { MAPIMessage msg = new MAPIMessage(getDocumentFromName(FILENAME_MAIL_WITH_ATTACHMENTS).getPath()); msg.setReturnNullOnMissingChunk(true); assertThat(msg.getDisplayFrom(), is("Nicolas Eysseric")); assertThat(msg.getRecipientDetailsChunks(), is(notNullValue())); assertThat(msg.getRecipientDetailsChunks().length, is(2)); assertThat(msg.getRecipientDetailsChunks()[0].getRecipientName(), is("Aurore ADR. DELISSNYDER")); assertThat(msg.getRecipientDetailsChunks()[0].getRecipientEmailAddress(), is("Aurore.DELISSNYDER@hydrostadium.fr")); assertThat(msg.getRecipientDetailsChunks()[1].getRecipientName(), is("Ludovic BERTIN")); assertThat(msg.getRecipientDetailsChunks()[1].getRecipientEmailAddress(), is("ludovic.bertin@oosphere.com")); AttachmentChunks[] attachments = msg.getAttachmentFiles(); assertThat(attachments, is(notNullValue())); assertThat(attachments.length, is(2)); if (attachments != null && attachments.length > 0) { System.out.print("\n"); for (AttachmentChunks attachmentChunks : attachments) { System.out.println(attachmentChunks.attachFileName.getValue()); } } else { System.out.println("None."); } System.out.println("DATE : " + DateUtil.getOutputDateAndHour(getMessageDate(msg), "fr")); System.out.println("BODY : "); System.out.println(">>>"); System.out.println(getMessageBody(msg)); System.out.println("<<<"); }
From source file:org.silverpeas.core.mail.MsgMailExtractorIT.java
License:Open Source License
/** * This unit test is support for MSG exploration solution testing. * * @throws Exception/*from www .j av a2 s .c o m*/ */ @Test public void readMailWithAttachmentsMSG() throws Exception { MAPIMessage msg = new MAPIMessage(getDocumentFromName(FILENAME_MAIL_WITH_ATTACHMENTS).getPath()); msg.setReturnNullOnMissingChunk(true); assertThat(msg.getDisplayFrom(), is("Nicolas Eysseric")); assertThat(msg.getRecipientDetailsChunks(), is(notNullValue())); assertThat(msg.getRecipientDetailsChunks().length, is(2)); assertThat(msg.getRecipientDetailsChunks()[0].getRecipientName(), is("Aurore ADR. DELISSNYDER")); assertThat(msg.getRecipientDetailsChunks()[0].getRecipientEmailAddress(), is("Aurore.DELISSNYDER@hydrostadium.fr")); assertThat(msg.getRecipientDetailsChunks()[1].getRecipientName(), is("Ludovic BERTIN")); assertThat(msg.getRecipientDetailsChunks()[1].getRecipientEmailAddress(), is("ludovic.bertin@oosphere.com")); AttachmentChunks[] attachments = msg.getAttachmentFiles(); assertThat(attachments, is(notNullValue())); assertThat(attachments.length, is(2)); if (attachments != null && attachments.length > 0) { System.out.print("\n"); for (AttachmentChunks attachmentChunks : attachments) { System.out.println(attachmentChunks.getAttachFileName().getValue()); } } else { System.out.println("None."); } System.out.println("DATE : " + DateUtil.getOutputDateAndHour(getMessageDate(msg), "fr")); System.out.println("BODY : "); System.out.println(">>>"); System.out.println(getMessageBody(msg)); System.out.println("<<<"); }