Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="flag"></param>
        /// <param name="value"></param>
        /// <param name="localOnly">Indicates if the flag should be set only on the local object, and not on the server</param>
        public bool SetMessageFlag(IMessage msg, MessageFlag flag, bool value, bool localOnly)
        {
            bool currentValue = _client.DataManager.GetValue <Message, bool>((Message)msg, flag.ToString());

            if (currentValue == value)
            {
                return(true);
            }
            _client.DataManager.SetValue(msg, flag.ToString(), value);
            if (localOnly)
            {
                return(true);
            }
            ChangeFlagRequest cfr = new ChangeFlagRequest(msg, flag, value, null);

            _client.RequestManager.SubmitRequest(cfr, true);

            return(cfr.Result.Response == IMAPResponse.IMAP_SUCCESS_RESPONSE);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="flag"></param>
        /// <param name="value"></param>
        public bool SetMessageFlag(IMessage msg, string flag, bool value)
        {
            bool currentValue = msg.GetCustomFlag(flag);

            if (currentValue == value)
            {
                return(true);
            }
            ChangeFlagRequest cfr = new ChangeFlagRequest(msg, flag, value, null);

            _client.RequestManager.SubmitAndWait(cfr, true);
            if (cfr.Result.Response != IMAPResponse.IMAP_SUCCESS_RESPONSE)
            {
                _client.RequestManager.SubmitAndWait(cfr, true);    // retry once
            }
            if (cfr.Result.Response == IMAPResponse.IMAP_SUCCESS_RESPONSE)
            {
                msg.SetCustomFlag(flag, value);
            }

            return(cfr.Result.Response == IMAPResponse.IMAP_SUCCESS_RESPONSE);
        }