Parsing emails using Tika
Asked Answered
V

0

6

I'm looking to parse an email .msg or .eml file using Tika. With the code below, I'm able to parse the email along with what is is inside of the attachment. However, I'd like to get the attachment text and name in a different object. Is this possible?

using (var stream = new BufferedInputStream(new FileInputStream(new File(pathToFile))))
                {
                    var parser = new AutoDetectParser();
                    var handler = new BodyContentHandler();
                    var metadata = new Metadata();
                    parser.parse(stream, handler, metadata, new ParseContext());
                    var text = handler.toString();
                }
Vibraphone answered 4/11, 2015 at 15:47 Comment(2)
Did you find a solution? It still actial problemParma
I ended up using MimeKit (this was for a c# project)Vibraphone

© 2022 - 2024 — McMap. All rights reserved.