Archived Forum Post

Index of archived forum posts

Question:

Moving messages from one mailbox to another

Mar 31 '14 at 14:24

Hello!

How can I move messages from one mailbox to another? For example, from Inbox to CustomFolder. I use next code for this:

            foreach (int uid in args.Uids)
            {
                if (_imap.Copy(uid, true, args.ToFolder))
                {
                    _imap.SetFlag(uid, true, "Deleted", 1);
                    copied.Add(uid);
                }
            }

            if (copied.Count > 0)
            {
                _imap.ExpungeAndClose();
             ....

I didn't find any method for moving.


Accepted Answer

The IMAP protocol itself does not provide a "MOVE to another folder" command. The only way to do it is to copy the email to another folder, and then delete it from the original folder.