Move Message

Feb 8, 2013 at 10:28 AM
I would like to know if its possible to move a message from inbox to other folder. My idea is an automatic process that get the new messages, extract the acttachments and move this message to other folder to avoid get processed again the next time.
Can u help me pls?
Im connecting with an IMAP server.
Feb 8, 2013 at 1:00 PM
Ok I answer myself, the way is that u must copy the message to the new folder, delteit from the actual one and expunge the client.

This is the code:
            imap.Connect(Imap4Server,143);
            imap.Login(UserName, Password);

            //Abrimos la bandeja de entrada
            Mailbox inbox = imap.SelectMailbox("Inbox");

            for (int n = 1; n < inbox.MessageCount+1; n++)
            {
                ActiveUp.Net.Mail.Message newMessage = inbox.Fetch.MessageObject(n);

                MoverTOX(imap, newMessage.MessageId);
                DeleteMessage(imap, newMessage.MessageId);
            }
            //salvamos los cambios realizados en el buzón
            imap.Expunge();

public static void MoveTOX(Imap4Client imap,string action_id)
    {
        Mailbox inbox = imap.SelectMailbox("Inbox");
        int[] ids = inbox.Search("ALL");
        if (ids.Length > 0)
        {
            ActiveUp.Net.Mail.Message msg = null;
            for (var i = 0; i < ids.Length; i++)
            {
                msg = inbox.Fetch.MessageObject(ids[i]);
                if (msg.MessageId == action_id)
                {
                    imap.Command("copy " + ids[i].ToString() + " Procesados");
                    return;
                }
            }
        }
    }

public static void DeleteMessage(Imap4Client imap,string action_id)
    {
        Mailbox inbox = imap.SelectMailbox("Inbox");
        int[] ids = inbox.Search("ALL");
        if (ids.Length > 0)
        {
            ActiveUp.Net.Mail.Message msg = null;
            for (var i = 0; i < ids.Length; i++)
            {
                msg = inbox.Fetch.MessageObject(ids[i]);
                if (msg.MessageId == action_id)
                {
                    FlagCollection flags = new FlagCollection();
                    flags.Add("Deleted");
                    inbox.AddFlags(ids[i], flags);
                    return;
                }
            }
        }
    }