Exemple #1
0
        /// <summary>
        /// Deletes the specified message
        /// </summary>
        /// <param name="msg">The message to delete</param>
        public void DeleteMessage(IMAPMessage msg)
        {
            if (_client.OfflineMode)
            {
                _client.Log(IMAPBase.LogTypeEnum.WARN, "Cannot delete messages in offline mode.");
                return;
            }

            string    cmd    = "UID STORE {0} +FLAGS (\\Deleted)\r\n";
            ArrayList result = new ArrayList();

            // first we need to put the folder in read/write mode by SELECTing it
            this.Select();
            // mark the specified message as deleted
            _client._imap.SendAndReceive(String.Format(cmd, msg.Uid), ref result);
            // EXPUNGE the \Deleted messages
            _client._imap.SendAndReceive("EXPUNGE\r\n", ref result);
            // remove the message object from the collection
            _messages.Remove(msg);
            // set the folder back to read-only mode
            this.Examine();
            _client.UpdateCache(true);
            _client.Log(IMAPBase.LogTypeEnum.INFO, String.Format("Message wih UID {0} in folder \"{1}\" successfully deleted.", msg.Uid, this.FolderName));
        }