// // IImapFolder.cs // // Author: Jeffrey Stedfast // // Copyright (c) 2013-2020 .NET Foundation and Contributors // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // using System.Threading; using System.Threading.Tasks; using System.Collections.Generic; using MimeKit; using MailKit.Search; namespace MailKit.Net.Imap { /// /// An interface for an IMAP folder. /// /// /// Implemented by . /// /// /// /// /// /// /// public interface IImapFolder : IMailFolder { /// /// Get the specified body part headers. /// /// /// Gets the specified body part headers. /// /// The body part headers. /// The UID of the message. /// The body part specifier. /// The cancellation token. /// The progress reporting mechanism. /// /// is null. /// /// /// is invalid. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The IMAP server did not return the requested body part headers. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// HeaderList GetHeaders (UniqueId uid, string partSpecifier, CancellationToken cancellationToken = default (CancellationToken), ITransferProgress progress = null); /// /// Asynchronously get the specified body part headers. /// /// /// Gets the specified body part headers. /// /// The body part headers. /// The UID of the message. /// The body part specifier. /// The cancellation token. /// The progress reporting mechanism. /// /// is null. /// /// /// is invalid. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The IMAP server did not return the requested body part headers. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// Task GetHeadersAsync (UniqueId uid, string partSpecifier, CancellationToken cancellationToken = default (CancellationToken), ITransferProgress progress = null); /// /// Get the specified body part headers. /// /// /// Gets the specified body part headers. /// /// The body part headers. /// The index of the message. /// The body part specifier. /// The cancellation token. /// The progress reporting mechanism. /// /// is out of range. /// /// /// is null. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The IMAP server did not return the requested body part headers. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// HeaderList GetHeaders (int index, string partSpecifier, CancellationToken cancellationToken = default (CancellationToken), ITransferProgress progress = null); /// /// Asynchronously get the specified body part headers. /// /// /// Gets the specified body part headers. /// /// The body part headers. /// The index of the message. /// The body part specifier. /// The cancellation token. /// The progress reporting mechanism. /// /// is out of range. /// /// /// is null. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The IMAP server did not return the requested body part headers. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// Task GetHeadersAsync (int index, string partSpecifier, CancellationToken cancellationToken = default (CancellationToken), ITransferProgress progress = null); /// /// Get the specified body part. /// /// /// Gets the specified body part. /// /// The body part. /// The UID of the message. /// The body part specifier. /// The cancellation token. /// The progress reporting mechanism. /// /// is null. /// /// /// is invalid. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The IMAP server did not return the requested message body. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// MimeEntity GetBodyPart (UniqueId uid, string partSpecifier, CancellationToken cancellationToken = default (CancellationToken), ITransferProgress progress = null); /// /// Asynchronously get the specified body part. /// /// /// Gets the specified body part. /// /// The body part. /// The UID of the message. /// The body part specifier. /// The cancellation token. /// The progress reporting mechanism. /// /// is null. /// /// /// is invalid. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The IMAP server did not return the requested message body. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// Task GetBodyPartAsync (UniqueId uid, string partSpecifier, CancellationToken cancellationToken = default (CancellationToken), ITransferProgress progress = null); /// /// Get the specified body part. /// /// /// Gets the specified body part. /// /// The body part. /// The index of the message. /// The body part specifier. /// The cancellation token. /// The progress reporting mechanism. /// /// is null. /// /// /// is out of range. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The IMAP server did not return the requested message. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// MimeEntity GetBodyPart (int index, string partSpecifier, CancellationToken cancellationToken = default (CancellationToken), ITransferProgress progress = null); /// /// Asynchronously get the specified body part. /// /// /// Gets the specified body part. /// /// The body part. /// The index of the message. /// The body part specifier. /// The cancellation token. /// The progress reporting mechanism. /// /// is null. /// /// /// is out of range. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The IMAP server did not return the requested message. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// Task GetBodyPartAsync (int index, string partSpecifier, CancellationToken cancellationToken = default (CancellationToken), ITransferProgress progress = null); /// /// Get the streams for the specified messages. /// /// /// Gets the streams for the specified messages. /// /// The uids of the messages. /// /// The cancellation token. /// The progress reporting mechanism. /// /// is null. /// -or- /// is null. /// /// /// One or more of the is invalid. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// void GetStreams (IList uids, ImapFetchStreamCallback callback, CancellationToken cancellationToken = default (CancellationToken), ITransferProgress progress = null); /// /// Asynchronously get the streams for the specified messages. /// /// /// Asynchronously gets the streams for the specified messages. /// /// An awaitable task. /// The uids of the messages. /// /// The cancellation token. /// The progress reporting mechanism. /// /// is null. /// -or- /// is null. /// /// /// One or more of the is invalid. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// Task GetStreamsAsync (IList uids, ImapFetchStreamAsyncCallback callback, CancellationToken cancellationToken = default (CancellationToken), ITransferProgress progress = null); /// /// Get the streams for the specified messages. /// /// /// Gets the streams for the specified messages. /// /// The indexes of the messages. /// /// The cancellation token. /// The progress reporting mechanism. /// /// is null. /// -or- /// is null. /// /// /// One or more of the is invalid. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// void GetStreams (IList indexes, ImapFetchStreamCallback callback, CancellationToken cancellationToken = default (CancellationToken), ITransferProgress progress = null); /// /// Asynchronously get the streams for the specified messages. /// /// /// Asynchronously gets the streams for the specified messages. /// /// An awaitable task. /// The indexes of the messages. /// /// The cancellation token. /// The progress reporting mechanism. /// /// is null. /// -or- /// is null. /// /// /// One or more of the is invalid. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// Task GetStreamsAsync (IList indexes, ImapFetchStreamAsyncCallback callback, CancellationToken cancellationToken = default (CancellationToken), ITransferProgress progress = null); /// /// Get the streams for the specified messages. /// /// /// Gets the streams for the specified messages. /// /// The minimum index. /// The maximum index, or -1 to specify no upper bound. /// /// The cancellation token. /// The progress reporting mechanism. /// /// is out of range. /// -or- /// is out of range. /// /// /// is null. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// void GetStreams (int min, int max, ImapFetchStreamCallback callback, CancellationToken cancellationToken = default (CancellationToken), ITransferProgress progress = null); /// /// Asynchronously get the streams for the specified messages. /// /// /// Asynchronously gets the streams for the specified messages. /// /// An awaitable task. /// The minimum index. /// The maximum index, or -1 to specify no upper bound. /// /// The cancellation token. /// The progress reporting mechanism. /// /// is out of range. /// -or- /// is out of range. /// /// /// is null. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// Task GetStreamsAsync (int min, int max, ImapFetchStreamAsyncCallback callback, CancellationToken cancellationToken = default (CancellationToken), ITransferProgress progress = null); /// /// Search the folder for messages matching the specified query. /// /// /// Sends a UID SEARCH command with the specified query passed directly to the IMAP server /// with no interpretation by MailKit. This means that the query may contain any arguments that a /// UID SEARCH command is allowed to have according to the IMAP specifications and any /// extensions that are supported, including RETURN parameters. /// /// An array of matching UIDs. /// The search query. /// The cancellation token. /// /// is null. /// /// /// is an empty string. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// SearchResults Search (string query, CancellationToken cancellationToken = default (CancellationToken)); /// /// Asynchronously search the folder for messages matching the specified query. /// /// /// Sends a UID SEARCH command with the specified query passed directly to the IMAP server /// with no interpretation by MailKit. This means that the query may contain any arguments that a /// UID SEARCH command is allowed to have according to the IMAP specifications and any /// extensions that are supported, including RETURN parameters. /// /// An array of matching UIDs. /// The search query. /// The cancellation token. /// /// is null. /// /// /// is an empty string. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// Task SearchAsync (string query, CancellationToken cancellationToken = default (CancellationToken)); /// /// Sort messages matching the specified query. /// /// /// Sends a UID SORT command with the specified query passed directly to the IMAP server /// with no interpretation by MailKit. This means that the query may contain any arguments that a /// UID SORT command is allowed to have according to the IMAP specifications and any /// extensions that are supported, including RETURN parameters. /// /// An array of matching UIDs. /// The search query. /// The cancellation token. /// /// is null. /// /// /// is an empty string. /// /// /// The IMAP server does not support the SORT extension. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// SearchResults Sort (string query, CancellationToken cancellationToken = default (CancellationToken)); /// /// Asynchronously sort messages matching the specified query. /// /// /// Sends a UID SORT command with the specified query passed directly to the IMAP server /// with no interpretation by MailKit. This means that the query may contain any arguments that a /// UID SORT command is allowed to have according to the IMAP specifications and any /// extensions that are supported, including RETURN parameters. /// /// An array of matching UIDs. /// The search query. /// The cancellation token. /// /// is null. /// /// /// is an empty string. /// /// /// The IMAP server does not support the SORT extension. /// /// /// The has been disposed. /// /// /// The is not connected. /// /// /// The is not authenticated. /// /// /// The is not currently open. /// /// /// The operation was canceled via the cancellation token. /// /// /// An I/O error occurred. /// /// /// The server's response contained unexpected tokens. /// /// /// The server replied with a NO or BAD response. /// Task SortAsync (string query, CancellationToken cancellationToken = default (CancellationToken)); } }