This project is read-only.

Mark as read and moving

Topics: Help requests
Mar 2, 2014 at 1:09 PM
Edited Mar 2, 2014 at 1:12 PM
Hi,
First to all, excellent work, thx for sharing to all!

I have reading and moving from inbox to XXX folder but message not delete easly.

First question, why MoveTo renamed to CopyTo and MoveTo implements Remove. ¿?

¿How can improve my code?
Messages = _mImapClient.Folders["INBOX"].Search().OrderByDescending(_ => _.Date).ToList();
and code:
                var folderdest = "Reads";
                Message msgDel = null;
                foreach (var mes in Messages.Where(mes => mes.UId == uid))
                {
                    mes.Seen = true;
                    foreach (var fld in _mImapClient.Folders["INBOX"].SubFolders.Where(fld => fld.Name == folderdest ))
                        mes.MoveTo(fld);
                    msgDel = mes;
                }
                if (msgDel!=null)
                    var resultdel = msgDel.Remove(); // <-- don't delete
Coordinator
Mar 2, 2014 at 10:52 PM
Edited Mar 2, 2014 at 10:53 PM
Hi Fastorro,

the method Message.CopyTo creates a copy of the message in the specified folder. The method Message.MoveTo however, creates a copy of the message in the specified folder, and then deletes it from the current folder. The methods do exactly what their names say.

Coming to your question about why the mehod Message.MoveTo uses Message.Remove: The IMAP protocol doesn't provide a way to move messages, only copy, that's why in order to move a message, we need to copy it, and then delete the original one.

I have an idea about improving your code, will post a sample here later.

Greets,

Pavel
Mar 3, 2014 at 11:58 AM
Ok thanks...

then i suggest CopyTo -> Clone() :P

If i move msg i will lose UID?

Thanks by you patience and improve code if you have free time ;)
Coordinator
Mar 3, 2014 at 1:16 PM
Hi Fastorro,

at the moment the UID is getting lost on move, however, it is a bug. If the server supports the UIDPLUS extension, then it will be possible to retrieve the UID. Just wait for the coming release, I will provide a fix for this.

About renaming CopyTo to Clone: For me, Clone would mean creating a copy of the message in same folder. The method CopyTo however, can create copies in other folders too.