Programming with Thunderbird
Reading Messages
Mozilla Thunderbird is an open source, cross-platform email client, developed by the Mozilla Foundation. It stores emails in its own file structure, managing messages indices and subfolders through proprietary file formats. Aspose.Email can work with Thunderbird mail storage structures. The MboxrdStorageReader class lets developers read messages from Mozilla Thunderbird’s mail storage file. This article shows how to read the messages from Thunderbird email storage:
- Open the Thunderbird’s storage file
- Create an instance of the MboxrdStorageReader class and pass the above stream to the constructor.
- Call read_next_message() to get the first message.
- Use the same read_next_message() in a while loop to read all the messages.
- Close all the streams.
The following code snippet shows you how to read all the messages from a Thunderbird mail storage.
Writing Messages
The MboxrdStorageWriter class provides the facility to write new messages to Thunderbird’s mail storage file. To write messages:
- Open the Thunderbird storage file in FileStream.
- Create an instance of the MboxrdStorageWriter class and pass the above stream to the constructor.
- Prepare a new message using the MailMessage class.
- Call the write_message() method and pass the above MailMessage instance to add the message to Thunderbird storage.
- Close all streams.
The following code snippet shows you how to writes messages to Thunderbird’s mail storage.
Getting Total Number of Messages from MBox File
The MboxrdStorageReader class provides the capability to read the number of items available in an MBox file. This can be used to develop applications for showing progress of activity while processing such a file.