2

I've outlook email data in the firm of EML files. There are various levels of nesting of attachments.

Is there a generic way to extract the attached .msg and its attachments recursively?

A full piece of code or relevant code snippet would be much more helpful than plain approach.

2
  • The JavaMail sample program msgshow.java should help. Commented Jan 18, 2018 at 19:16
  • So is it an EML file or an MSG file? Commented Apr 30, 2018 at 17:14

1 Answer 1

1

You might consider using a library called msgparser.

They list some very basic usage examples:

MsgParser msgp = new MsgParser();
Message msg = msgp.parseMsg("mail.msg");

String fromEmail = msg.getFromEmail();
String fromName = msg.getFromName();
String subject = msg.getSubject();

List<Attachment> atts = msg.getAttachments();
for (Attachment att : atts) {
  // do something with attachment
}
Sign up to request clarification or add additional context in comments.

1 Comment

the function List<Attachment> atts = msg.getAttachments(); for (Attachment att : atts) { // do something with attachment } is returning file name like abc.pdf, now how can I get this abc.pdf or how can I open it, its returning only attachment name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.