0 votes

How to 'Archive' message in email using IMAP?

by

1 Answer

0 votes
 
Best answer

You just need to use Imap.DeleteMessageByUID() method when INBOX folder is selected.

imap.SelectInbox(); 
List<long> uids = imap.Search(Expression.Subject("to archive"));
imap.DeleteMessageByUID(uids);

After this, emails are still available through "All Mail" IMAP folder.

https://www.limilabs.com/blog/archive-email-in-gmail

Note that if you use DeleteMessageByUID when other folder/label is selected, Gmail will not archive the message, but rather remove currently selected label.

by (301k points)
edited by
...