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:

  1. Open the Thunderbird’s storage file in FileStream.
  2. Create an instance of the MboxrdStorageReader class and pass the above stream to the constructor.
  3. Call ReadNextMessage() to get the first message.
  4. Use the same ReadNextMessage() in a while loop to read all the messages.
  5. 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:

  1. Open the Thunderbird storage file in FileStream.
  2. Create an instance of the MboxrdStorageWriter class and pass the above stream to the constructor.
  3. Prepare a new message using the MailMessage class.
  4. Call the WriteMessage() method and pass the above MailMessage instance to add the message to Thunderbird storage.
  5. 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.

Get Current Message Size