Package org.apache.poi.hsmf

Examples of org.apache.poi.hsmf.MAPIMessage


            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

    */
   public void testWithAttachments() throws Exception {
      POIFSFileSystem simple = new POIFSFileSystem(
            new FileInputStream(samples.getFile("attachment_test_msg.msg"))
      );
      MAPIMessage msg = new MAPIMessage(simple);
      OutlookTextExtactor ext = new OutlookTextExtactor(msg);
     
      // Check the normal bits
      String text = ext.getText();
     
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

   * Initialize this test, load up the blank.msg mapi message.
   * @throws Exception
   */
  public TestSimpleFileRead() throws IOException {
        POIDataSamples samples = POIDataSamples.getHSMFInstance();
    this.mapiMessage = new MAPIMessage(samples.openResourceAsStream("simple_test_msg.msg"));
  }
View Full Code Here

  /**
   * Initialize this test, load up the blank.msg mapi message.
   */
  public TestBlankFileRead() throws IOException {
        POIDataSamples samples = POIDataSamples.getHSMFInstance();
    this.mapiMessage = new MAPIMessage(samples.openResourceAsStream("blank.msg"));
  }
View Full Code Here

      simple.getRoot().getEntry(
            (new StringChunk(MAPIProperty.SENDER_NAME.id, Types.ASCII_STRING)).getEntryName()
      );
     
      // Now load the file
      MAPIMessage msg = new MAPIMessage(simple);
      try {
         assertEquals("Kevin Roast", msg.getDisplayTo());
         assertEquals("Kevin Roast", msg.getDisplayFrom());
         assertEquals("Test the content transformer", msg.getSubject());
      } catch(ChunkNotFoundException e) {
         fail();
      }
     
      // Check date too
      try {
         SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        
         Calendar c = msg.getMessageDate();
         assertEquals( "2007-06-14 09:42:55", f.format(c.getTime()) );
      } catch(ChunkNotFoundException e) {
         fail();
      }
   }
View Full Code Here

     
      String search = new String(recips.recipientSearchChunk.getValue(), "ASCII");
      assertEquals("CN=KEVIN.ROAST@BEN\0", search.substring(search.length()-19));
     
      // Now via MAPIMessage
      MAPIMessage msg = new MAPIMessage(simple);
      assertNotNull(msg.getRecipientDetailsChunks());
      assertEquals(1, msg.getRecipientDetailsChunks().length);
     
      assertEquals("kevin.roast@alfresco.org", msg.getRecipientDetailsChunks()[0].recipientSMTPChunk.getValue());
      assertEquals("kevin.roast@alfresco.org", msg.getRecipientDetailsChunks()[0].getRecipientEmailAddress());
      assertEquals("Kevin Roast", msg.getRecipientDetailsChunks()[0].getRecipientName());
      assertEquals("kevin.roast@alfresco.org", msg.getRecipientEmailAddress());
     
     
      // Try both SMTP and EX files for recipient
      assertEquals("EX", msg.getRecipientDetailsChunks()[0].deliveryTypeChunk.getValue());
      assertEquals("kevin.roast@alfresco.org", msg.getRecipientDetailsChunks()[0].recipientSMTPChunk.getValue());
      assertEquals("/O=HOSTEDSERVICE2/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=Kevin.roast@ben",
            msg.getRecipientDetailsChunks()[0].recipientEmailChunk.getValue());
     
      // Now look at another message
      msg = new MAPIMessage(new POIFSFileSystem(
            new FileInputStream(samples.getFile("simple_test_msg.msg"))
      ));
      assertNotNull(msg.getRecipientDetailsChunks());
      assertEquals(1, msg.getRecipientDetailsChunks().length);
     
      assertEquals("SMTP", msg.getRecipientDetailsChunks()[0].deliveryTypeChunk.getValue());
      assertEquals(null, msg.getRecipientDetailsChunks()[0].recipientSMTPChunk);
      assertEquals(null, msg.getRecipientDetailsChunks()[0].recipientNameChunk);
      assertEquals("travis@overwrittenstack.com", msg.getRecipientDetailsChunks()[0].recipientEmailChunk.getValue());
      assertEquals("travis@overwrittenstack.com", msg.getRecipientEmailAddress());
   }
View Full Code Here

   * Initialize this test, load up the blank.msg mapi message.
   * @throws Exception
   */
  public TestOutlook30FileRead() throws IOException {
        POIDataSamples samples = POIDataSamples.getHSMFInstance();
    this.mapiMessage = new MAPIMessage(samples.openResourceAsStream("outlook_30_msg.msg"));
  }
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.