Beispiel #1
0
        /// <summary>
        /// Gets the folder for the specified path.
        /// </summary>
        /// <returns>The folder.</returns>
        /// <param name="path">The folder path.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="path"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ObjectDisposedException">
        /// The <see cref="ImapClient"/> has been disposed.
        /// </exception>
        /// <exception cref="System.InvalidOperationException">
        /// <para>The <see cref="ImapClient"/> is not connected.</para>
        /// <para>-or-</para>
        /// <para>The <see cref="ImapClient"/> is not authenticated.</para>
        /// </exception>
        /// <exception cref="FolderNotFoundException">
        /// The folder could not be found.
        /// </exception>
        public IFolder GetFolder(string path, CancellationToken cancellationToken)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            CheckDisposed();

            if (!IsConnected)
            {
                throw new InvalidOperationException("The ImapClient is not connected.");
            }

            if (engine.State != ImapEngineState.Authenticated && engine.State != ImapEngineState.Selected)
            {
                throw new InvalidOperationException("The ImapClient is not authenticated.");
            }

            return(engine.GetFolder(path, cancellationToken));
        }