Class MboxStorageReader
Contents
[
Hide
]MboxStorageReader class
Represents an MBOX file and provides methods for reading and extracting messages. The MBOX file format is used for storing a collection of email messages.
public abstract class MboxStorageReader : IDisposable
Properties
Name | Description |
---|---|
BaseStream { get; } | Gets the base stream. |
CurrentDataSize { get; } | Gets the number of bytes that is read by ReadNextMessage method. |
Methods
Name | Description |
---|---|
static CreateReader(Stream, MboxLoadOptions) | Creates the instance of reader. |
static CreateReader(string, MboxLoadOptions) | Creates the instance of reader. |
static CreateReader(Stream, MboxLoadOptions, CancellationToken) | Creates the instance of reader. |
static CreateReader(string, MboxLoadOptions, CancellationToken) | Creates the instance of reader. |
Dispose() | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
EnumerateMessageInfo() | Exposes the enumerator, which supports an iteration of messages in storage. |
EnumerateMessages() | Exposes the enumerator, which supports an iteration of messages in storage. |
EnumerateMessages(EmlLoadOptions) | Exposes the enumerator, which supports an iteration of messages in storage. |
ExtractMessage(string, EmlLoadOptions) | Get the message from MBOX. |
abstract GetTotalItemsCount() | Returns the number of messages in a storage. |
abstract NextMessage() | Gets the next message info. |
abstract ReadNextMessage() | Reads the next message from underlying storage stream. |
abstract ReadNextMessage(EmlLoadOptions) | Reads the next message from underlying storage stream. |
abstract ReadNextMessage(out string) | Reads the next message from underlying storage stream. |
abstract ReadNextMessage(out string, EmlLoadOptions) | Reads the next message from underlying storage stream. |
SplitInto(long, string) | Splits the mbox storage into less sized parts. |
SplitInto(long, string, CancellationToken) | Splits the mbox storage into less sized parts. |
SplitInto(long, string, string) | |
SplitInto(long, string, string, CancellationToken) | Splits the mbox storage into less sized parts. |
Events
Name | Description |
---|---|
event EmlCopied | Event that occurs after successful copy of a MailMessage object within the SplitInto method. |
event EmlCopying | Event that occurs before the MailMessage object copy process, within the SplitInto method. |
event MboxFileCreated | Event that occurs when a new MBOX file is created during the SplitInto method. |
event MboxFileFilled | Event that occurs after filling an MBOX file with data within the SplitInto method. |
Examples
The following code provided is intended for processing email messages stored in an MBOX file using the MboxStorageReader class.
[C#]
// Create an instance of the MboxStorageReader using the factory method 'CreateReader'.
var mbox = MboxStorageReader.CreateReader("storage.mbox", new MboxLoadOptions());
// Iterate through each message info object in the mbox storage.
foreach (var mboxMessageInfo in mbox.EnumerateMessageInfo())
{
Console.WriteLine($"Subject: {mboxMessageInfo.Subject}");
Console.WriteLine($"From: {mboxMessageInfo.From}");
Console.WriteLine($"To: {mboxMessageInfo.To}");
// Extract the full MIME message object from the MBOX storage using the message's unique entry ID.
var eml = mbox.ExtractMessage(mboxMessageInfo.EntryId, new EmlLoadOptions());
// Save the extracted MIME message as an .eml file.
eml.Save($"{eml.Subject}.eml");
}
[Visual Basic]
' Create an instance of the MboxStorageReader using the factory method 'CreateReader'.
Dim mbox As MboxStorageReader = MboxStorageReader.CreateReader("storage.mbox", New MboxLoadOptions())
' Iterate through each message info object in the mbox storage.
For Each mboxMessageInfo As var In mbox.EnumerateMessageInfo()
Console.WriteLine($"Subject: {mboxMessageInfo.Subject}")
Console.WriteLine($"From: {mboxMessageInfo.From}")
Console.WriteLine($"To: {mboxMessageInfo.To}")
' Extract the full MIME message object from the MBOX storage using the message's unique entry ID.
Dim eml As var = mbox.ExtractMessage(mboxMessageInfo.EntryId, New EmlLoadOptions())
' Save the extracted MIME message as an .eml file.
eml.Save($"{eml.Subject}.eml")
Next
See Also
- namespace Aspose.Email.Storage.Mbox
- assembly Aspose.Email