Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help Needed !! #16

Closed
payadav opened this issue Mar 3, 2020 · 3 comments
Closed

Help Needed !! #16

payadav opened this issue Mar 3, 2020 · 3 comments
Labels
inactive Should be closed shortly

Comments

@payadav
Copy link

payadav commented Mar 3, 2020

Hi,

I am trying to extract Parsing and Msg convertion ability from this code. My requirement is build a REST api interface to convert .msg file in to .eml file.
I am more or less able to convert .msg file to Message object using MsgParser like below

MsgParser parser = new MsgParser();
Message msg = parser.parseMsg(new File("C:\Users\xyz\workspace\projects\demo\xyz.msg"));

However i am facing challenged in converting Message object to eml file using MsgWriter

MsgWriter writer = new MsgWriter();
writer.write(msg, new FileOutputStream("C:\Users\xyz\workspace\projects\demo\xyz.eml"));

These are the contents of my MsgContainer.write() method

public void write(Message msg, OutputStream out) throws IOException {
NPOIFSFileSystem fs = new NPOIFSFileSystem();
DirectoryNode root = fs.getRoot();
MsgContainer cont = new MsgContainer(msg);
cont.write(root);
fs.writeFilesystem(out);
fs.close();
}

Exception i see is

2020-03-03 10:52:37.069 INFO 18036 --- [nio-8080-exec-1] com.example.msgparser.MsgContainer : Msgontainer -> write null
2020-03-03 10:52:37.071 INFO 18036 --- [nio-8080-exec-1] c.example.msgparser.entries.SubstGEntry : SubstGEntry -> 55 - 31
2020-03-03 10:52:37.071 INFO 18036 --- [nio-8080-exec-1] c.example.msgparser.entries.SubstGEntry : __substg1.0_0037001F
2020-03-03 10:52:37.084 ERROR 18036 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: Can't read from a new stream before it has been written to] with root cause

java.lang.IllegalStateException: Can't read from a new stream before it has been written to

Please let me know if this is making sense or if you need more information.
Any help is much appreciated.

@payadav
Copy link
Author

payadav commented Mar 4, 2020

Do you think you would be able to help me on this ?

@lolo101
Copy link
Owner

lolo101 commented Mar 8, 2020

Hi @payadav, this is funny, you have the exact same requirement as in #15

MsgWriter's purpose is to write .msg files. You may want to look at class MessageParserFactory, especially around line 63 : https://github.com/lolo101/MsgViewer/blob/01c8db511085eefb8cdd6d13fafeac58592c3ed0/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/MessageParserFactory.java

For a hint about how to write a .eml file

@lolo101
Copy link
Owner

lolo101 commented Jan 2, 2022

Hello @payadav, could you resolve the problem? I intend to close this issue in the next few days if it is no more needed

@lolo101 lolo101 added the inactive Should be closed shortly label Jan 3, 2022
@lolo101 lolo101 closed this as completed Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive Should be closed shortly
Projects
None yet
Development

No branches or pull requests

2 participants