Package org.apache.poi.hsmf

Examples of org.apache.poi.hsmf.MAPIMessage


    } else if(ext instanceof PowerPointExtractor) {
      // Tricky, not stored directly in poifs
      // TODO
    } else if(ext instanceof OutlookTextExtactor) {
       // Stored in the Attachment blocks
       MAPIMessage msg = ((OutlookTextExtactor)ext).getMAPIMessage();
       for(AttachmentChunks attachment : msg.getAttachmentFiles()) {
          if(attachment.attachData != null) {
             byte[] data = attachment.attachData.getValue();
             nonPOIFS.add( new ByteArrayInputStream(data) );
          }
       }
View Full Code Here


     */
    public Reader extractText(InputStream stream,
                              String type,
                              String encoding) throws IOException {
        try {
          MAPIMessage message = new MAPIMessage(stream);
          StringBuffer buffer = new StringBuffer();
          buffer.append(message.getDisplayFrom()).append('\n');
          buffer.append(message.getDisplayTo()).append('\n');
          buffer.append(message.getSubject()).append('\n');
          buffer.append(message.getTextBody());
            return new StringReader(buffer.toString());
        } catch (Exception e) {
            logger.warn("Failed to extract Message content", e);
            return new StringReader("");
        } finally {
View Full Code Here

    public OutlookExtractor(NPOIFSFileSystem filesystem, ParseContext context) throws TikaException {
        super(context);
       
        try {
            this.msg = new MAPIMessage(filesystem.getRoot());
        } catch (IOException e) {
            throw new TikaException("Failed to parse Outlook message", e);
        }
    }
View Full Code Here

    } else if(ext instanceof PowerPointExtractor) {
      // Tricky, not stored directly in poifs
      // TODO
    } else if(ext instanceof OutlookTextExtactor) {
       // Stored in the Attachment blocks
       MAPIMessage msg = ((OutlookTextExtactor)ext).getMAPIMessage();
       for(AttachmentChunks attachment : msg.getAttachmentFiles()) {
          if(attachment.attachData != null) {
                byte[] data = attachment.attachData.getValue();
                nonPOIFS.add( new ByteArrayInputStream(data) );
          } else if(attachment.attachmentDirectory != null) {
              dirs.add(attachment.attachmentDirectory.getDirectory());
View Full Code Here

     * Treats the directory as an embeded MAPIMessage
     *  (it normally is one), and returns a MAPIMessage
     *  object to process it with.
     */
    public MAPIMessage getAsEmbededMessage() throws IOException {
        return new MAPIMessage(dir);
    }
View Full Code Here

 
   public void testQuick() throws Exception {
      POIFSFileSystem simple = new POIFSFileSystem(
            new FileInputStream(samples.getFile("quick.msg"))
      );
      MAPIMessage msg = new MAPIMessage(simple);
     
      OutlookTextExtactor ext = new OutlookTextExtactor(msg);
      String text = ext.getText();
     
      assertContains(text, "From: Kevin Roast\n");
View Full Code Here

      assertContains(text, "Date: " + dateText + "\n");
      assertContains(text, "The quick brown fox jumps over the lazy dog");
   }
  
   public void testSimple() throws Exception {
      MAPIMessage msg = new MAPIMessage(new POIFSFileSystem(
            new FileInputStream(samples.getFile("simple_test_msg.msg"))
      ));
     
      OutlookTextExtactor ext = new OutlookTextExtactor(msg);
      String text = ext.getText();
View Full Code Here

            samples.getFile("simple_test_msg.msg")
      )).getText());
      String poifs = (new OutlookTextExtactor(new POIFSFileSystem(new FileInputStream(
            samples.getFile("simple_test_msg.msg")
      ))).getText());
      String mapi = (new OutlookTextExtactor(new MAPIMessage(new FileInputStream(
            samples.getFile("simple_test_msg.msg")
      ))).getText());
     
      assertEquals(inp, poifs);
      assertEquals(inp, mapi);
View Full Code Here

     
      String[] files = new String[] {
            "example_sent_regular.msg", "example_sent_unicode.msg"
      };
      for(String file : files) {
         MAPIMessage msg = new MAPIMessage(new POIFSFileSystem(
               new FileInputStream(samples.getFile(file))
         ));
        
         OutlookTextExtactor ext = new OutlookTextExtactor(msg);
         String text = ext.getText();
View Full Code Here

     
      String[] files = new String[] {
            "example_received_regular.msg", "example_received_unicode.msg"
      };
      for(String file : files) {
         MAPIMessage msg = new MAPIMessage(new POIFSFileSystem(
               new FileInputStream(samples.getFile(file))
         ));
        
         OutlookTextExtactor ext = new OutlookTextExtactor(msg);
         String text = ext.getText();
View Full Code Here

TOP

Related Classes of org.apache.poi.hsmf.MAPIMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.