Read the complete article on how to write and read messages from Thunderbird storage in Java: https://blog.aspose.com/2022/02/20/write-and-read-messages-on-thunderbird-storage-in-java/
Last active
April 20, 2022 17:12
-
-
Save aspose-com-gists/4587f4f70b733eebc36f247bd79c7fdc to your computer and use it in GitHub Desktop.
Write and Read Messages on Thunderbird Storage in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load file | |
try (FileInputStream stream = new FileInputStream("file.mbox")) { | |
// Create load options | |
MboxLoadOptions lo = new MboxLoadOptions(); | |
lo.setLeaveOpen(false); | |
// Read messages from file | |
try (MboxrdStorageReader reader = new MboxrdStorageReader(stream, lo)) { | |
MailMessage msg; | |
String[] fromMarker = {null}; | |
while ((msg = reader.readNextMessage(/* out */fromMarker)) != null) { | |
System.out.println(fromMarker[0]); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load file | |
try (FileOutputStream writeStream = new FileOutputStream("inbox")) { | |
// Create writer | |
try (MboxrdStorageWriter writer = new MboxrdStorageWriter(writeStream, false)) { | |
// Load message from MSG file | |
MailMessage msg = MailMessage.load("Message.msg"); | |
String[] fromMarker = {null}; | |
// Write message | |
writer.writeMessage(msg, fromMarker); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment