Class MboxMessageCollection
An in-memory collection of MIME messages loaded from or destined for an MBOX file. Convenience wrapper around MboxReader and MboxWriter. For large archives, prefer the streaming reader/writer directly.
Inherited Members
Namespace: DRIT.Mail.Rfc.Mbox
Assembly: DRIT.Mail.dll
Syntax
public sealed class MboxMessageCollection : IEnumerable<MimeMessage>, IEnumerable
Constructors
View SourceMboxMessageCollection()
Initializes a new, empty instance of the MboxMessageCollection class.
Declaration
public MboxMessageCollection()
Properties
View SourceCount
Gets the number of messages in the collection.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
this[int]
Gets the message at the specified index.
Declaration
public MimeMessage this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index |
Property Value
| Type | Description |
|---|---|
| MimeMessage | The message at the specified index. |
Methods
View SourceAdd(MimeMessage)
Adds a message to the collection. The From line is derived from the message when the collection is saved.
Declaration
public void Add(MimeMessage message)
Parameters
| Type | Name | Description |
|---|---|---|
| MimeMessage | message | The message to add. |
Add(MimeMessage, MboxFromLine)
Adds a message to the collection with an explicit From line.
Declaration
public void Add(MimeMessage message, MboxFromLine fromLine)
Parameters
| Type | Name | Description |
|---|---|---|
| MimeMessage | message | The message to add. |
| MboxFromLine | fromLine | The From line to use when writing this message. |
AddRange(IEnumerable<MimeMessage>)
Adds a range of messages to the collection.
Declaration
public void AddRange(IEnumerable<MimeMessage> messages)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<MimeMessage> | messages | The messages to add. |
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<MimeMessage> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<MimeMessage> |
Load(Stream)
Loads all messages from an MBOX stream.
Declaration
public static MboxMessageCollection Load(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream to read from. The stream is closed by this method. |
Returns
| Type | Description |
|---|---|
| MboxMessageCollection | A collection containing all messages in the stream. |
Load(string)
Loads all messages from an MBOX file.
Declaration
public static MboxMessageCollection Load(string fileName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileName | The path to the MBOX file. |
Returns
| Type | Description |
|---|---|
| MboxMessageCollection | A collection containing all messages in the file. |
Save(Stream)
Saves all messages in this collection to an MBOX stream.
Declaration
public void Save(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream to write to. The stream is flushed but not closed. |
Save(string)
Saves all messages in this collection to an MBOX file.
Declaration
public void Save(string fileName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileName | The path to the MBOX file to write. |