{"id":2240,"date":"2012-01-06T12:54:01","date_gmt":"2012-01-06T10:54:01","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/?p=2240"},"modified":"2014-05-16T10:16:46","modified_gmt":"2014-05-16T08:16:46","slug":"archive-email-in-gmail","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/archive-email-in-gmail","title":{"rendered":"Archive email in Gmail"},"content":{"rendered":"<p>First remember to <a href=\"\/blog\/enable-imap-in-gmail\">enable IMAP in Gmail<\/a>.<\/p>\n<p>To archive message in Gmail you need to use <em>DeleteMessageByUID <\/em>method. Using <strong>INBOX <\/strong>folder is crucial for Archiving to work. If you use <em>DeleteMessageByUID <\/em> when other folder\/label is selected, Gmail will not archive the message, but rather remove currently selected label.<\/p>\n<p>After this operation messages will be still available in &#8220;All Mail&#8221; IMAP folder.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ C#\r\n\r\nusing(Imap imap = new Imap())\r\n{\r\n\timap.ConnectSSL(&quot;imap.gmail.com&quot;);\r\n\timap.Login(&quot;user&quot;, &quot;password&quot;);\r\n\r\n\t\/\/ Find all emails we want to delete\r\n\timap.SelectInbox();\r\n\tList&lt;long&gt; uids = imap.Search(\r\n\t\tExpression.Subject(&quot;email to archive&quot;));\r\n\r\n\timap.DeleteMessageByUID(uids);\r\n\r\n\timap.Close();\r\n}\r\n<\/pre>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n' VB.NET\r\n\r\nUsing imap As New Imap()\r\n\timap.ConnectSSL(&quot;imap.gmail.com&quot;)\r\n\timap.Login(&quot;user@gmail.com&quot;, &quot;password&quot;)\r\n\r\n\t' Find all emails we want to delete\r\n\timap.SelectInbox()\r\n\tDim uids As List(Of Long) = imap.Search(_\r\n\t\tExpression.Subject(&quot;email to archive&quot;))\r\n\r\n\timap.DeleteMessageByUID(uids)\r\n\r\n\timap.Close()\r\nEnd Using\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>First remember to enable IMAP in Gmail. To archive message in Gmail you need to use DeleteMessageByUID method. Using INBOX folder is crucial for Archiving to work. If you use DeleteMessageByUID when other folder\/label is selected, Gmail will not archive the message, but rather remove currently selected label. After this operation messages will be still [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[15,25,28,77,57],"class_list":["post-2240","post","type-post","status-publish","format-standard","hentry","category-mail-dll","tag-c","tag-gmail","tag-imap","tag-imap-component","tag-vb-net"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/2240"}],"collection":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/comments?post=2240"}],"version-history":[{"count":7,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/2240\/revisions"}],"predecessor-version":[{"id":4068,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/2240\/revisions\/4068"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=2240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=2240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=2240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}