Crystalbyte.Equinox.Imap.ImapClient.Close C# (CSharp) Method

Close() public method

The CLOSE command permanently removes all messages that have the \Deleted flag set from the currently selected mailbox, and returns to the authenticated state from the selected state.
public Close ( string mailboxName ) : Crystalbyte.Equinox.Imap.Responses.ImapResponse
mailboxName string The targeted mailboxName.
return Crystalbyte.Equinox.Imap.Responses.ImapResponse
        public ImapResponse Close(string mailboxName)
        {
            // we need to convert non ASCII names according to IMAP specs.
            // http://tools.ietf.org/html/rfc2060#section-5.1.3
            var name = MailboxNameEncoder.Encode(mailboxName);

            var text = string.Format("CLOSE {0}", name);
            var command = new ImapCommand(text);
            var reader = SendAndReceive(command);

            var response = new ImapResponse();
            response.Parse(reader);

            if (response.IsOk) {
                SelectedMailbox = string.Empty;
            }

            return response;
        }