MboxReader Class
Reads the messages of an mbox file, the format of the mailboxes of Unix mail tools and of Thunderbird: messages one after the other, each one after a line that starts with From . The messages are read one at a time.
public static class MboxReaderExample
foreach (var entry in MboxReader.ReadMessages(path, new MboxReadOptions { Format = MboxFormat.Mboxrd }))
{
// The envelope sender and the date of the "From " line, then the message, read when it is accessed
var sender = entry.Sender;
var subject = entry.Message.Subject;
Assert.NotNull(sender);
Assert.NotNull(subject);
}Methods
| Name | Description |
|---|---|
| ReadMessages(Stream, MboxReadOptions?) | Reads the messages of an mbox stream, until its end. |
| ReadMessages(string, MboxReadOptions?) | Reads the messages of an mbox file. |
ReadMessages overloads
ReadMessages(Stream, MboxReadOptions?)
MboxReader.csReads the messages of an mbox stream, until its end.
public static IEnumerable<MboxMessage> ReadMessages(Stream stream, MboxReadOptions? options = null)Parameters
streamStream- The stream.
optionsMboxReadOptions?- The options, or
nullfor the default options.
Returns
IEnumerable<MboxMessage> The messages, read as they are enumerated.
Exceptions
InvalidEmailDataException- The stream does not start with a
Fromline, or aContent-Lengthheader does not end a message. EmailResourceLimitException- A message is larger than
MimeReadOptions.MaxSize.
ReadMessages(string, MboxReadOptions?)
MboxReader.csReads the messages of an mbox file.
public static IEnumerable<MboxMessage> ReadMessages(string path, MboxReadOptions? options = null)Parameters
pathstring- The path of the file.
optionsMboxReadOptions?- The options, or
nullfor the default options.
Returns
IEnumerable<MboxMessage> The messages, read as they are enumerated.
Exceptions
InvalidEmailDataException- The file does not start with a
Fromline, or aContent-Lengthheader does not end a message. EmailResourceLimitException- A message is larger than
MimeReadOptions.MaxSize.