How can i fetch read/unread status and the size of a mail message which is extracted from a mbox file?
You can use the following code to extract messages from MBox file and check if it is read or not?
// Open the storage file with FileStream
FileStream stream = new FileStream(dataDir + "ExampleMbox.mbox", FileMode.Open, FileAccess.Read);
// Create an instance of the MboxrdStorageReader class and pass the stream
MboxrdStorageReader reader = new MboxrdStorageReader(stream, false);
// Start reading messages
MailMessage message = reader.ReadNextMessage();
// Read all messages in a loop
while (message != null)
{
// Manipulate message - show contents
Console.WriteLine("Subject: " + message.Subject);
Console.WriteLine(message.IsDraft);
// Get the next message
message = reader.ReadNextMessage();
}
// Close the streams
reader.Dispose();
stream.Close();
Use the code sample in section Get Current Message Size section to read the size of message extracted from the MBox.
Thank You sir…
But how can i fetch read/uread status of the mail message?
There is no such information available in MailMessage that can get you this information. You need to convert the message to MapiMessage and check its message flags for read/unread information.
bool isread = (mapi.Flags & MapiMessageFlags.MSGFLAG_READ) == MapiMessageFlags.MSGFLAG_READ;