Class MboxReader
Reads MBOX mailbox files (RFC 4155) from a stream, yielding one MimeMessage per stored message. Reads lazily: the underlying stream is consumed as messages are enumerated, so arbitrarily large archives can be processed without loading the whole file into memory. Not thread-safe.
Implements
Inherited Members
Namespace: DRIT.Mail.Rfc.Mbox
Assembly: DRIT.Mail.dll
Syntax
public sealed class MboxReader : IDisposable
Constructors
View SourceMboxReader(Stream)
Initializes a new instance of the MboxReader class.
Declaration
public MboxReader(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream used to read or write the data. |
MboxReader(Stream, bool)
Initializes a new instance of the MboxReader class.
Declaration
public MboxReader(Stream stream, bool leaveOpen)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream used to read or write the data. |
| bool | leaveOpen | The leave open used by the operation. |
Properties
View SourceCurrentFromLine
Gets the From line of the message most recently returned by ReadMessage(), or null if no message has been read.
Declaration
public MboxFromLine? CurrentFromLine { get; }
Property Value
| Type | Description |
|---|---|
| MboxFromLine |
CurrentIndex
Gets the zero-based index of the message most recently returned by ReadMessage(), or -1 if none.
Declaration
public int CurrentIndex { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
View SourceDispose()
Processes the dispose data.
Declaration
public void Dispose()
ReadAllMessages()
Enumerates all remaining messages in the stream.
Declaration
public IEnumerable<MimeMessage> ReadAllMessages()
Returns
| Type | Description |
|---|---|
| IEnumerable<MimeMessage> | An enumerable of all remaining messages. |
ReadFromLine()
Reads the next message's From line (envelope sender + timestamp), or null at end of file. Does not advance past the message body. A subsequent call to ReadMessage() will return the message associated with this From line.
Declaration
public MboxFromLine? ReadFromLine()
Returns
| Type | Description |
|---|---|
| MboxFromLine |
ReadMessage()
Reads the next message, or null at end of file. The returned MimeMessage does not include the From line; the From line is exposed separately via CurrentFromLine.
Declaration
public MimeMessage? ReadMessage()
Returns
| Type | Description |
|---|---|
| MimeMessage |