Imap Class
Provides properties and methods for connecting to an IMAP4 server, downloading, searching, and managing folders and e-mail messages in a user account.
Inheritance Hierarchy
SystemObject
  MailBee.ImapMailImap

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax
public class Imap : IComponent, IDisposable

The Imap type exposes the following members.

Constructors
  NameDescription
Public methodImap
Creates an instance of Imap class.
Public methodImap(String)
Creates and unlocks an instance of Imap class.
Top
Methods
  NameDescription
Public methodAbort
Forces MailBee to cancel all pending operations and close all opened connections as soon as possible.
Public methodCode exampleBeginClose Obsolete.
Begins an asynchronous request for closing (unselecting) the currently selected folder and optional removing of messages marked as deleted from this folder.
Public methodCode exampleBeginConnect Obsolete.
Begins an asynchronous request for a connecting to an IMAP4 server.
Public methodCode exampleBeginCopyOrMoveMessages Obsolete.
Begins an asynchronous request for copying or moving the specified messages from the currently selected folder to the specified folder.
Public methodBeginDisconnect Obsolete.
Begins an asynchronous request for a disconnection from the mail server.
Public methodCode exampleBeginDownloadEnvelopes Obsolete.
Begins an asynchronous request for downloading the specified message elements (envelopes, flags, body structures, entire messages or message headers, etc) from the currently selected folder.
Public methodCode exampleBeginDownloadEnvelopesEx Obsolete.
Begins an asynchronous request for downloading the specified sets of message items (for each message, its own set of items can be requested) from the currently selected folder.
Public methodCode exampleBeginDownloadFolders Obsolete.
Begins an asynchronous request for downloading IMAP folders matching the specified criteria.
Public methodCode exampleBeginExecuteCustomCommand Obsolete.
Begins an asynchronous request for sending the specified user-defined command to the server and getting the response.
Public methodCode exampleBeginIdle Obsolete.
Begins an asynchronous request for starting idling mode.
Public methodCode exampleBeginLogin Obsolete.
Begins an asynchronous request for a logging in an account on an IMAP4 server.
Public methodCode exampleBeginSearch Obsolete.
Begins an asynchronous request for searching the currently selected folder for messages meeting the specified criteria.
Public methodCode exampleBeginSelectFolder Obsolete.
Begins an asynchronous request for selecting a folder in an account on an IMAP4 server.
Public methodCode exampleBeginSetMessageFlags Obsolete.
Begins an asynchronous request to set or reset the specified message flags for the specified messages in the currently selected folder.
Public methodCode exampleBeginSortedSearch Obsolete.
Begins an asynchronous request for searching the currently selected folder for messages meeting the specified criteria and sorting them accordingly the specified sort condition.
Public methodCode exampleBeginStartTls Obsolete.
Begins an asynchronous request to start TLS/SSL negotiation with the server.
Public methodCode exampleBeginUploadMessage Obsolete.
Begins an asynchronous request for uploading the message into the specified folder on the server.
Public methodCode exampleClose
Unselects the currently selected folder and removes all messages having \Deleted flag set from the folder.
Public methodClose(Boolean)
Unselects the currently selected folder and optionally removes all messages having \Deleted flag set from the folder.
Public methodCloseAsync
Public methodCloseAsync(Boolean)
async/await version of Close(Boolean).
Public methodCode exampleConnect(String)
Connects to an IMAP4 server on the standard IMAP4 port (143).
Public methodCode exampleConnect(String, Int32)
Connects to an IMAP4 server.
Public methodCode exampleConnect(String, Int32, Socket, EndPoint)
Connects to an IMAP4 server.
Public methodConnectAsync(String)
async/await version of Connect(String).
Public methodConnectAsync(String, Int32)
async/await version of Connect(String, Int32).
Public methodConnectAsync(String, Int32, Socket, EndPoint)
Public methodCode exampleCopyMessages(String, Boolean, String)
Copies the specified messages from the currently selected folder to the specified folder.
Public methodCode exampleCopyMessages(String, Boolean, String, UidPlusResult)
Copies the specified messages from the currently selected folder to the specified folder, and retrieves UIDs assigned to the copied messages in the destination folder.
Public methodCopyMessagesAsync(String, Boolean, String)
async/await version of CopyMessages(String, Boolean, String).
Public methodCopyMessagesAsync(String, Boolean, String, UidPlusResult)
Public methodCode exampleCreateFolder
Creates a new folder (mailbox in IMAP4 terms) in the IMAP4 account.
Public methodCreateFolderAsync
async/await version of CreateFolder(String).
Public methodCode exampleDeleteFolder
Deletes an existing folder (mailbox in IMAP4 terms) from the IMAP4 account.
Public methodDeleteFolderAsync
async/await version of DeleteFolder(String).
Public methodCode exampleDeleteMessages
Marks the specified messages in the currently selected folder as deleted.
Public methodDeleteMessagesAsync
async/await version of DeleteMessages(String, Boolean).
Public methodCode exampleDisconnect
Disconnects from the IMAP4 server and releases any used resources.
Public methodDisconnectAsync
Public methodDispose
Closes all opened network connections (if any) and releases any used system resources.
Protected methodDispose(Boolean)
When overridden in a derived class, must release unmanaged and optionally managed resources used by the component.
Public methodCode exampleDownloadEntireMessage
Completely downloads the specified message from the server.
Public methodDownloadEntireMessageAsync
async/await version of DownloadEntireMessage(Int64, Boolean).
Public methodCode exampleDownloadEntireMessages
Completely downloads the specified messages from the server.
Public methodDownloadEntireMessagesAsync
async/await version of DownloadEntireMessages(String, Boolean).
Public methodCode exampleDownloadEnvelopes(String, Boolean)
Fetches message envelopes from the server.
Public methodCode exampleDownloadEnvelopes(String, Boolean, EnvelopeParts, Int32)
Fetches message envelopes, bodies, headers, flags, attributes, and other message-related information from the server.
Public methodCode exampleDownloadEnvelopes(String, Boolean, EnvelopeParts, Int32, String, String)
Fetches message envelopes, bodies, headers, flags, attributes, and other message-related information from the server.
Public methodDownloadEnvelopesAsync(String, Boolean)
async/await version of DownloadEnvelopes(String, Boolean).
Public methodDownloadEnvelopesAsync(String, Boolean, EnvelopeParts, Int32)
Public methodDownloadEnvelopesAsync(String, Boolean, EnvelopeParts, Int32, String, String)
Public methodCode exampleDownloadEnvelopesEx
Fetches message envelopes, bodies, headers, flags, attributes, etc from the server allowing you to request different items for every message in the list.
Public methodDownloadEnvelopesExAsync
Public methodCode exampleDownloadFolders
Downloads the list of all IMAP folders of the mail account.
Public methodCode exampleDownloadFolders(Boolean)
Downloads the list of IMAP folders of the mail account.
Public methodCode exampleDownloadFolders(Boolean, String, String)
Downloads the list of IMAP folders matching the specified criteria.
Public methodDownloadFoldersAsync
Public methodDownloadFoldersAsync(Boolean)
async/await version of DownloadFolders(Boolean).
Public methodDownloadFoldersAsync(Boolean, String, String)
Public methodCode exampleDownloadMessageHeaders
Downloads the header of each message in the specified set from the server.
Public methodDownloadMessageHeadersAsync
async/await version of DownloadMessageHeaders(String, Boolean).
Public methodEndClose
Ends the pending asynchronous close folder request.
Public methodEndConnect
Ends the pending asynchronous connection request.
Public methodEndCopyOrMoveMessages
Ends a pending asynchronous request for copying or moving messages.
Public methodEndDisconnect
Ends a pending asynchronous disconnection request.
Public methodEndDownloadEnvelopes
Ends the pending asynchronous download envelopes request.
Public methodEndDownloadEnvelopesEx
Ends the pending asynchronous request of pipelined downloading envelopes.
Public methodEndDownloadFolders
Ends the pending asynchronous download folders request.
Public methodEndExecuteCustomCommand
Ends the pending asynchronous request for sending user-defined command to the server.
Public methodEndIdle
Ends the pending asynchronous request for idling termination.
Public methodEndLogin
Ends the pending asynchronous login request.
Public methodEndSearch
Ends the pending asynchronous search request.
Public methodEndSelectFolder
Ends the pending asynchronous select folder request.
Public methodEndSetMessageFlags
Ends a pending asynchronous setting message flags request.
Public methodEndSortedSearch
Ends the pending asynchronous sorted search request.
Public methodEndStartTls
Ends a pending asynchronous TLS/SSL negotiation request.
Public methodEndUploadMessage
Ends the pending asynchronous upload message request.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodCode exampleExamineFolder
Selects the specified folder (mailbox in IMAP4 terms) for read-only access.
Public methodExamineFolderAsync
async/await version of ExamineFolder(String).
Public methodCode exampleExecuteCustomCommand
Sends user-defined command to the server and receives the server response to this command.
Public methodExecuteCustomCommandAsync
async/await version of ExecuteCustomCommand(String, String).
Public methodCode exampleExpunge
Permanently removes all the messages marked as deleted from the currently selected folder.
Public methodCode exampleExpunge(String, Boolean)
Permanently removes the messages marked as deleted from the currently selected folder.
Public methodExpungeAsync
Public methodExpungeAsync(String, Boolean)
async/await version of Expunge(String, Boolean).
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodCode exampleGetAccountQuota
Gets the quota (resource usage limit) of the entire mail account on the server.
Public methodGetAccountQuotaAsync
Public methodGetErrorDescription
Returns a textual description of the last occurred error.
Public methodCode exampleGetExtension
Returns the name of the specified IMAP4 capability if it's supported by the mail server.
Public methodCode exampleGetExtensions
Returns a reference to the key-value list of the mail server capabilities.
Public methodCode exampleGetFolderQuota
Gets the quota (resource usage limit) of the specified folder.
Public methodGetFolderQuotaAsync
async/await version of GetFolderQuota(String).
Public methodCode exampleGetFolderSize
Downloads the size of each message in the currently selected folder and returns the total size occupied by all messages in this folder.
Public methodGetFolderSizeAsync
Public methodCode exampleGetFolderStatus
Gets the status of the specified folder without selecting it.
Public methodGetFolderStatusAsync
async/await version of GetFolderStatus(String).
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodCode exampleGetNamespaces
Downloads the list of IMAP4 namespaces available for the currently logged mail user.
Public methodGetNamespacesAsync
Public methodGetServerResponse
Returns the last response from the server.
Public methodGetServerResponses
Returns the specified individual responses from the last group of responses received from the server.
Public methodGetSocket
Returns the underlying Socket MailBee uses for the current network connection.
Public methodGetSocketError
Returns a Win32 error code of the last socket-related error.
Public methodCode exampleGetSpecialFolder
Gets a reference to the special folder of the specified kind.
Public methodGetStream
Returns the underlying Stream MailBee uses for the current network connection.
Public methodCode exampleGetSupportedAuthMethods
Returns a set of flags indicating which authentication methods are supported by the server.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodCode exampleIdle
Attempts to start idling mode which makes the client wait for any notifications from the server regarding the currently selected folder.
Public methodIdleAsync
Public methodCode exampleLogin(String, String)
Logs in a mail account on the IMAP4 server.
Public methodCode exampleLogin(String, String, AuthenticationMethods)
Logs in a mail account on the IMAP4 server.
Public methodCode exampleLogin(String, String, AuthenticationMethods, AuthenticationOptions, SaslMethod)
Logs in a mail account on the IMAP4 server.
Public methodCode exampleLogin(String, String, String, String, AuthenticationMethods, AuthenticationOptions, SaslMethod)
Logs in a mail account on the IMAP4 server.
Public methodLoginAsync(String, String)
async/await version of Login(String, String).
Public methodLoginAsync(String, String, AuthenticationMethods)
Public methodLoginAsync(String, String, AuthenticationMethods, AuthenticationOptions, SaslMethod)
Public methodLoginAsync(String, String, String, String, AuthenticationMethods, AuthenticationOptions, SaslMethod)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodCode exampleMoveMessages(String, Boolean, String)
Moves the specified messages from the currently selected folder to the specified folder.
Public methodCode exampleMoveMessages(String, Boolean, String, UidPlusResult)
Moves the specified messages from the currently selected folder to the specified folder, and retrieves UIDs assigned to the moved messages in the destination folder.
Public methodMoveMessagesAsync(String, Boolean, String)
async/await version of MoveMessages(String, Boolean, String).
Public methodMoveMessagesAsync(String, Boolean, String, UidPlusResult)
Public methodNoop
Sends a NOOP command to the mail server.
Public methodNoopAsync
Protected methodOnConnected
Used by MailBee to raise Connected event.
Protected methodOnDataReceived
Used by MailBee to raise DataReceived event.
Protected methodOnDataSent
Used by MailBee to raise DataSent event.
Protected methodOnDisconnected
Used by MailBee to raise Disconnected event.
Protected methodOnEnvelopeDataChunkReceived
Used by MailBee to raise EnvelopeDataChunkReceived event.
Protected methodOnEnvelopeDownloaded
Used by MailBee to raise EnvelopeDownloaded event.
Protected methodOnErrorOccurred
Used by MailBee to raise ErrorOccurred event.
Protected methodOnHostResolved
Used by MailBee to raise HostResolved event.
Protected methodOnIdling
Used by MailBee to raise Idling event.
Protected methodOnLoggedIn
Used by MailBee to raise LoggedIn event.
Protected methodOnLogNewEntry
Used by MailBee to raise LogNewEntry event.
Protected methodOnLowLevelDataReceived
Used by MailBee to raise LowLevelDataReceived event.
Protected methodOnLowLevelDataSent
Used by MailBee to raise LowLevelDataSent event.
Protected methodOnMessageStatus
Used by MailBee to raise MessageStatus event.
Protected methodOnServerStatus
Used by MailBee to raise ServerStatus event.
Protected methodOnSocketConnected
Used by MailBee to raise SocketConnected event.
Protected methodOnSocketCreating
Used by MailBee to raise SocketCreating event.
Protected methodOnTlsStarted
Used by MailBee to raise TlsStarted event.
Public methodStatic memberCode exampleQuickDownloadMessage(String, String, String, String, Int32)
Completely downloads the specified message from the specified folder on the server, in a single line of code.
Public methodStatic memberCode exampleQuickDownloadMessage(String, String, String, String, Int32, Int32)
Downloads the specified message (entire message or message header only) from the specified folder on the server, in a single line of code.
Public methodStatic memberCode exampleQuickDownloadMessages(String, String, String, String)
Completely downloads all the messages in the specified folder on the server, in a single line of code.
Public methodStatic memberCode exampleQuickDownloadMessages(String, String, String, String, Int32)
Downloads all the messages (entire messages or message headers only) in the specified folder on the server, in a single line of code.
Public methodCode exampleRenameFolder
Renames an existing folder (mailbox in IMAP4 terms) of the IMAP4 account.
Public methodRenameFolderAsync
async/await version of RenameFolder(String, String).
Public methodResetState
Resets the internal state of the component.
Public methodCode exampleSearch
Returns the collection of UIDs of all messages in the currently selected folder.
Public methodCode exampleSearch(Boolean, String, String)
Searches the currently selected folder for messages that meet the specified criteria.
Public methodSearchAsync
Public methodCode exampleSearchAsync(Boolean, String, String)
async/await version of Search(Boolean, String, String).
Public methodCode exampleSelectFolder
Selects the specified folder (mailbox in IMAP4 terms) for read-write access.
Public methodSelectFolderAsync
async/await version of SelectFolder(String).
Public methodCode exampleSetMessageFlags(String, Boolean, SystemMessageFlags, MessageFlagAction)
Sets or resets the specified flags for the specified messages in the currently selected folder.
Public methodCode exampleSetMessageFlags(String, Boolean, String, MessageFlagAction, Boolean)
Sets or resets the specified flags for the specified messages in the currently selected folder.
Public methodSetMessageFlagsAsync(String, Boolean, SystemMessageFlags, MessageFlagAction)
Public methodSetMessageFlagsAsync(String, Boolean, String, MessageFlagAction, Boolean)
Public methodCode exampleSortedSearch
Searches the currently selected folder for messages that meet the specified criteria and returns them as a collection sorted by the specified condition.
Public methodSortedSearchAsync
Public methodCode exampleStartTls
Requests the mail server to start TLS/SSL negotiation and protect the existing connection with a security layer.
Public methodStartTlsAsync
Public methodStopIdle
Notifies MailBee to terminate idling when appropriate.
Public methodSubscribeFolder
Subscribes to the specified folder (mailbox in IMAP4 terms) of the IMAP4 account.
Public methodSubscribeFolderAsync
async/await version of SubscribeFolder(String).
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodUnsubscribeFolder
Unsubscribes the previously subscribed folder (mailbox in IMAP4 terms) of the IMAP4 account.
Public methodUnsubscribeFolderAsync
async/await version of UnsubscribeFolder(String).
Public methodCode exampleUploadMessage(MailMessage, String)
Uploads a mail message to the specified folder.
Public methodCode exampleUploadMessage(MailMessage, String, SystemMessageFlags)
Uploads a mail message to the specified folder and assigns the specified flags to this message.
Public methodCode exampleUploadMessage(MailMessage, String, String, DateTime)
Uploads a mail message to the specified folder and assigns the specified date and flags to this message.
Public methodCode exampleUploadMessage(MailMessage, String, String, String)
Uploads a mail message to the specified folder and assigns the specified date and flags to this message.
Public methodCode exampleUploadMessage(MailMessage, String, String, String, Boolean, UidPlusResult)
Uploads a mail message to the specified folder, assigns the specified date and flags to this message, and retrieves UID assigned to the uploaded message by the server.
Public methodUploadMessageAsync(MailMessage, String)
async/await version of UploadMessage(MailMessage, String).
Public methodUploadMessageAsync(MailMessage, String, SystemMessageFlags)
Public methodUploadMessageAsync(MailMessage, String, String, DateTime)
Public methodUploadMessageAsync(MailMessage, String, String, String)
Public methodUploadMessageAsync(MailMessage, String, String, String, Boolean, UidPlusResult)
Public methodWait Obsolete.
Waits until the currently running (if any) asynchronous method is finished.
Public methodWait(Int32) Obsolete.
Waits the completion of the currently running (if any) asynchronous method for the specified amount of time.
Top
Fields
  NameDescription
Public fieldStatic memberAllMessages
Specifies the message set (sequence) which includes all messages in the folder.
Top
Properties
  NameDescription
Public propertyEnableLastDownloaded
Gets or sets whether MailBee should save currently downloaded envelopes in LastDownloadedEnvelopes property.
Public propertyFlags
Gets the flags that are applicable for the currently selected folder.
Public propertyIsAborted
Indicates whether Abort method has been called for the component.
Public propertyIsBusy
Indicates whether the component is performing a lengthy operation.
Public propertyIsConnected
Indicates whether the component is connected to the server.
Public propertyIsFolderSelected
Indicates if a folder is currently selected in the mail account.
Public propertyIsIdle
Gets if the component is in IDLE state.
Public propertyIsLoggedIn
Indicates whether the component has already successfully authenticated on the server and logged in the user account.
Public propertyIsSslConnection
Indicates whether the current connection (if any) is secured with TLS/SSL layer.
Public propertyCode exampleLastDownloadedEnvelopes
Gets the collection of the envelopes downloaded to the current moment.
Public propertyLastResult
Gets a numeric code of the last error.
Public propertyStatic memberLicenseKey Obsolete.
Assigns the license key.
Public propertyCode exampleLog
Gets the object used for logging MailBee activities into a file or memory buffer.
Public propertyMessageCount
Gets the number of messages in the currently selected folder.
Public propertyPermanentFlags
Gets the flags the client can change permanently.
Public propertyCode exampleProxy
Provides access to the settings which allow MailBee to connect to a mail server via a proxy server.
Public propertyRaiseEvents
Gets or sets whether the component will raise any events.
Public propertyRaiseEventsViaMessageLoop
Gets or sets whether the events will be raised on the message loop of the application or not.
Public propertyRecentCount
Gets the number of recent messages in the currently selected folder.
Public propertyRequestEncoding
Gets or sets the encoding used to convert a string into a bytes stream which is then sent to the mail server.
Public propertyResponseEncoding
Gets or sets the encoding used to convert a byte data received from the mail server into a string.
Public propertySetSeenForEntireMessages
Specifies if MailBee should also set SEEN flag when downloading entire messages.
Public propertySite
Gets or sets the object to be used as a site for the component.
Public propertyCode exampleSslCertificates
Provides access to the client and server SSL certificate settings.
Public propertyCode exampleSslMode
Gets or sets how the component should establish TLS/SSL connection with the mail server.
Public propertySslProtocol
Gets or sets the security protocol to be used for performing TLS/SSL negotiation and data encryption.
Public propertySynchronizingObject
Gets or sets the object used to marshal the calls of the event handlers.
Public propertyThrowExceptions
Gets or sets whether the component will throw exceptions on errors.
Public propertyTimeout
Gets or sets the amount of time (in milliseconds) the component will wait for a response from the server.
Public propertyTrialDaysLeft
Gets the number of days left to the date of the trial license key expiration.
Public propertyUidNext
Gets the UID to be assigned to the next message in the currently selected folder.
Public propertyUidValidity
Gets the UIDVALIDITY value of the currently selected folder.
Public propertyUnseen
Gets the ordinal message number of the first message which does not have "\Seen" flag set.
Public propertyUseXList
Gets or sets whether to use XLIST extension which allows the application to detect special folders like Sent, Drafts, Trash.
Public propertyUtf7EncodeFolderNames
Gets or sets whether MailBee should automatically encode folder names with UTF-7 Modified encoding.
Public propertyVersion
Gets the version of the MailBee assembly.
Top
Events
  NameDescription
Public eventCode exampleConnected
Occurs when the connection with the server is successfully established.
Public eventCode exampleDataReceived
Occurs when data is received from the IMAP4 server.
Public eventCode exampleDataSent
Occurs when data is sent to the IMAP4 server.
Public eventCode exampleDisconnected
Occurs when the connection with the server gets closed.
Public eventDisposed
Occurs after the component was disposed.
Public eventCode exampleEnvelopeDataChunkReceived
Occurs on progress of downloading FETCH responses (containing message source data, envelopes, and other message-related information) from the server.
Public eventCode exampleEnvelopeDownloaded
Public eventCode exampleErrorOccurred
Occurs when the MailBeeException is thrown.
Public eventCode exampleHostResolved
Occurs when the IMAP4 server name is successfully resolved into IP address(es).
Public eventCode exampleIdling
Ticks every 10 milliseconds while in idle state.
Public eventCode exampleLoggedIn
Occurs when the component successfully authenticates the user on the server and logs in the user account.
Public eventCode exampleLogNewEntry
Occurs when an entry is written into the log file (or into the memory buffer if Imap.Log.MemoryLog is true).
Public eventCode exampleLowLevelDataReceived
Occurs when data is received from the connected socket.
Public eventCode exampleLowLevelDataSent
Occurs when data is sent to the connected socket.
Public eventCode exampleMessageStatus
Occurs when the IMAP4 server informs the client of any changes to mail messages in the currently selected folder.
Public eventCode exampleServerStatus
Occurs when the IMAP4 server reports mailbox or server status information to the client.
Public eventCode exampleSocketConnected
Occurs when the IMAP4 server accepts the connection attempt and opens the transmission channel between the remote host (IMAP4 server) and the client (MailBee).
Public eventCode exampleSocketCreating
Occurs when MailBee needs a new socket object for establishing a connection with the IMAP4 server.
Public eventCode exampleTlsStarted
Occurs when the connection with the server becomes secure.
Top
Remarks
You can perform the following operations using this class:
  • Download entire messages with body and attachments
  • Download message headers (and optionally, the part of message bodies)
  • Download message envelopes or any parts or attributes of messages
  • Download and manage IMAP4 folders, detect special folders like Drafts or Trash
  • Delete messages from the server, examine and set message flags
  • Send user-defined commands to the IMAP4 server
  • Login to a user account using a number of authentication methods (including secure methods and OAuth2)
  • Process multiple messages in a batch
  • Search messages
  • Upload, copy, and move messages between folders
  • Collect folder and accounts statistics like number of messages and total size of all messages
  • Download entire messages or message headers with a single line of code (using static methods)
  • Take advantage of many IMAP4 extensions (QUOTA, IDLE, SORT, UIDPLUS, MOVE, CHILDREN, XLIST, SPECIAL-USE, LITERAL+, and Gmail-specific)
  • Work with IMAP4 namespaces (e.g. Public folders)
  • Establish secure connection with TLS/SSL enabled IMAP4 server
  • Establish connection via a proxy server (SOCKS4, SOCKS5, and HTTP proxy are supported)
Examples
This sample connects to an IMAP4 server, logs in using the most secure method supported by this server, downloads envelopes for the last 10 messages in the inbox, and prints From:, To:, and Subject: field values for every message into Console, newer messages first.
using System;
using MailBee;
using MailBee.ImapMail;

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

        // Connect to the server, login and select inbox.
        imp.Connect("mail.somecompany.com");
        imp.Login("jdoe@somecompany.com", "secret");
        imp.SelectFolder("INBOX");

        string range;

        // Does the inbox contain at least 10 mails?
        if (imp.MessageCount >= 10)
        {
            // We'll get last 10 mails.
            range = (imp.MessageCount - 9).ToString() + ":" + "*";
        }
        else
        {
            // We'll get all mails.
            range = Imap.AllMessages;
        }

        // Get envelopes for the specified messages.
        EnvelopeCollection envelopes = imp.DownloadEnvelopes(range, false);

        // Make newer messages be displayed first.
        envelopes.Reverse();

        foreach (Envelope env in envelopes)
        {
            Console.WriteLine("Message #" + env.MessageNumber);
            Console.WriteLine("From: " + env.From.ToString());
            Console.WriteLine("To: " + env.To.ToString());
            Console.WriteLine("Subject: " + env.Subject);
            Console.WriteLine();
        }

        // Disconnect from the server.
        imp.Disconnect();
    }
}
See Also