Programming with Thunderbird
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 in FileStream.
- Create an instance of the MboxrdStorageReader class and pass the above stream to the constructor.
- Call ReadNextMessage() to get the first message.
- Use the same ReadNextMessage() 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.
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 WriteMessage() 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 the progress of activity while processing such a file.