Reputation: 706
Is there any way (open source way) to convert Outlook .msg to MimeMessage so that someone can work with msg files in Java?
There is a library named MsgParser developed for working with .msg files but this library does not give an option to convert .msg to MimeMessage, it has its own Message class. I really need to convert the msg to MimeMessage.
If there is no way to do it in Java, is there any open-source tool for linux which makes conversion from command line?
Upvotes: 2
Views: 4108
Reputation: 708
You can use this code to convert outlooks msg files to eml. I picked up the code and library from: https://github.com/ctabin/jotlmsg Note that jotlmsg requires apache POI + dependencies and Javax.mail
package MsgToMime;
import ch.astorm.jotlmsg.OutlookMessage;
import java.io.File;
import javax.mail.internet.MimeMessage;
public class MsgToMime {
public static void main(String args[]) throws Throwable{
OutlookMessage message0 = new OutlookMessage(new File("myMessage.msg"));
MimeMessage mimeMessage = message0.toMimeMessage();
mimeMessage.writeTo(new FileOutputStream(new File("myMessage.eml")));
}
}
Upvotes: 2