Я написал ниже код для проверки преобразования почты из bababab.msg в объект MimeMessage.Пример сообщения взят из outlook2010.Я получаю «NoClassDefFoundError» при попытке выполнить метод преобразования.
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javax.mail.internet.MimeMessage;
import org.simplejavamail.converter.EmailConverter;
public class TestMail {
public static void main(String[] args) {
FileInputStream fis;
try {
File msg = new File("C:\\Users\\bababa\\Desktop\\samplemail\\bababab.msg");
if (msg.exists()) {
System.out.println("File exist");
}
fis = new FileInputStream(msg);
MimeMessage mimeMessage = EmailConverter.outlookMsgToMimeMessage(fis);
if (null != mimeMessage) {
System.out.println("Success");
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Журнал ошибок:
File exist
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/poi/poifs/filesystem/DirectoryEntry
at org.simplejavamail.converter.internal.msgparser.OutlookMessageParser.parseOutlookMsg(OutlookMessageParser.java:35)
at org.simplejavamail.converter.EmailConverter.outlookMsgToEmailBuilder(EmailConverter.java:100)
at org.simplejavamail.converter.EmailConverter.outlookMsgToEmail(EmailConverter.java:92)
at org.simplejavamail.converter.EmailConverter.outlookMsgToMimeMessage(EmailConverter.java:142)
at TestMail.main(TestMail.java:22)
Caused by: java.lang.ClassNotFoundException:
org.apache.poi.poifs.filesystem.DirectoryEntry
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 5 more