MailMessageCollectionReverse Method |
Reverses the order of the list of the messages that are stored in the collection.
Namespace: MailBee.MimeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax Remarks For instance, this method can be used to display the list of message received from mail server
in descending order (from new to old ones). By default, mail server returns messages in ascending order (from old to new ones).
This method allows the developer to have this collection re-sorted in descending order.
Examples The sample creates new collection, loads 4 messages from .EML files,
adds these messages to the collection, and displays the subjects of these messages. Then, the collection is
reversed and the subjects of the messages are shown again (in reverse order).
using MailBee;
using MailBee.Mime;
MailMessageCollection msgColl = new MailMessageCollection();
MailMessage msg = new MailMessage();
for (int i = 1; i < 5; i++)
{
msg.LoadMessage(string.Format(@"C:\Docs\TestMail{0}.eml", i));
msgColl.Add(msg);
}
foreach (MailMessage m in msgColl)
{
Console.WriteLine(m.Subject);
}
msgColl.Reverse();
foreach (MailMessage m in msgColl)
{
Console.WriteLine(m.Subject);
}
Imports MailBee
Imports MailBee.Mime
Dim msgColl As MailMessageCollection = New MailMessageCollection
Dim msg As New MailMessage
Dim i As Integer
For i = 1 To 4
msg.LoadMessage(String.Format("C:\Docs\TestMail{0}.eml", i))
msgColl.Add(msg)
Next
For Each m As MailMessage In msgColl
Console.WriteLine(m.Subject)
Next
msgColl.Reverse()
For Each m As MailMessage In msgColl
Console.WriteLine(m.Subject)
Next
See Also