MailBee.NET Objects 4.0

Imap.ExamineFolder Method 

Selects the specified folder (mailbox in IMAP4 terms) for read-only access.

public bool ExamineFolder(
   string folderName
);

Parameters

folderName
The full name of the folder to be selected.

Return Value

true if the folder was selected successfully; otherwise, false.

Remarks

When the folder is selected for read-only access, the selected folder is identified as read-only. No changes to the permanent state of the folder, including per-user state, are permitted; in particular, when messages are downloaded, they won't lose the \Recent flag.

To select the folder for read-write access, the developer should use SelectFolder method.

The developer should specify the full name of the folder (including all parent folders' names if the folder is subfolder of another existing folder). See CreateFolder topic for details regarding folder names.

Exceptions

Exception TypeCondition
MailBeeExceptionAn error occurred and ThrowExceptions is true.

Example

This sample connects to the IMAP4 server, logs in the mail account, selects Inbox folder in read-only mode, and downloads the last message without loosing \Recent flag (if the message has this flag set).

[C#]
using System;
using MailBee;
using MailBee.ImapMail;
using MailBee.Mime;

class Sample
{
    static void Main(string[] args)
    {
        Imap imp = new Imap();

        // Connect to the server and log in the account.
        imp.Connect("mail.domain.com");
        imp.Login("jdoe", "secret");

        // Select the folder in read-only mode.
        imp.ExamineFolder("Inbox");

        if (imp.MessageCount > 0)
        {
            // Download and save last message into a file.
            // If the message is recent, it won't loose \Recent flag.
            MailMessage msg = imp.DownloadEntireMessage(imp.MessageCount, false);
            msg.SaveMessage(@"C:\Temp\msg.eml");
        }

        imp.Disconnect();
    }
}
[Visual Basic]
Imports System
Imports MailBee
Imports MailBee.ImapMail
Imports MailBee.Mime

Module Sample

    Sub Main(ByVal args As String())
        ' The actual code (put it into a method of your class)
        Dim imp As New Imap

        ' Connect to the server and log in the account.
        imp.Connect("imap4.company.com")
        imp.Login("jdoe@company.com", "secret")

        ' Select the folder in read-only mode.
        imp.ExamineFolder("Inbox")

        If imp.MessageCount > 0 Then
            ' Download and save last message into a file.
            ' If the message is recent, it won't loose \Recent flag.
            Dim msg As MailMessage = imp.DownloadEntireMessage(imp.MessageCount, False)
            msg.SaveMessage("C:\Temp\msg.eml")
        End If

        imp.Disconnect()
    End Sub
End Module

See Also

Imap Class | MailBee.ImapMail Namespace | SelectFolder | IsFolderSelected