Example #1
0
 /// <summary>
 ///   The STORE command alters data associated with a message in the mailbox.
 ///   http://tools.ietf.org/html/rfc2060#section-6.4.6
 /// </summary>
 /// <param name = "set">The sequence set representing the targeted messages, e.g. "1"; "1,2"; "2:4".</param>
 /// <param name = "flags">The flags to add or remove.</param>
 /// <param name = "procedure">The procedure, whether to add or remove the flags.</param>
 public ImapResponse StoreSilent(SequenceSet set, MessageFlags flags, StoreProcedures procedure)
 {
     var value = flags.ToMimeFormat();
     return StoreSilent(set, value, procedure);
 }
Example #2
0
        /// <summary>
        ///   The APPEND command appends the literal argument as a new message
        ///   to the end of the specified destination mailbox.
        ///   http://tools.ietf.org/html/rfc3501#section-6.3.11
        /// </summary>
        /// <param name = "mailboxName">The name of the malbox to insert the message.</param>
        /// <param name = "message">The message to append.</param>
        /// <param name = "flags">Sets the flags of the message. This is optional.</param>
        public ImapResponse Append(string mailboxName, Message message, MessageFlags flags = (MessageFlags) 0x0000)
        {
            // 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 mime = message.ToMime();
            var size = mime.Length;
            var flagString = flags == 0x0000 ? string.Empty : string.Format(" ({0})", flags.ToMimeFormat());
            var text = string.Format("APPEND {0}{1} {{{2}}}", name, flagString, size);
            var reader = SendAndReceive(new ImapCommand(text));

            if (reader.IsContinuation) {
                var finalReader = SendAndReceive(new BlankImapCommand(mime));

                var validResponse = new ImapResponse();
                validResponse.Parse(finalReader);
                return validResponse;
            }

            var invalidResponse = new ImapResponse();
            invalidResponse.Parse(reader);
            return invalidResponse;
        }