{"id":30,"date":"2018-09-03T23:16:34","date_gmt":"2018-09-03T23:16:34","guid":{"rendered":"https:\/\/www.newbranch.org\/wordpress\/?p=30"},"modified":"2018-09-03T23:17:22","modified_gmt":"2018-09-03T23:17:22","slug":"30","status":"publish","type":"post","link":"https:\/\/www.newbranch.org\/wordpress\/?p=30","title":{"rendered":"GMail Scripts"},"content":{"rendered":"<p><a id=\"post-30-_6gstzrn0xxt9\"><\/a><br \/>\nGMail isn\u2019t an Enterprise email client like Microsoft Outlook. It has some gaps. One of those gaps is to automatically mark the messages as Read when they go into the Trash folder. Unfortunately GMail doesn\u2019t natively mark theses messages as read. Thankfully Google has a scripts web site that can accomplish this task. Below are the steps.<\/p>\n<h2><a id=\"post-30-_a14xvyqj5nc0\"><\/a>Create the script<\/h2>\n<ol>\n<li>Go to the site <a href=\"https:\/\/script.google.com\">https:\/\/script.google.com<\/a>.<\/li>\n<li>Login if you already haven\u2019t done so.<\/li>\n<li>Click on the <strong>New Script<\/strong> button.<\/li>\n<li>A new window will appear to where you can enter in the text for the script.<\/li>\n<li>Give your project a name.<\/li>\n<li>Enter in the code in the text window.<\/li>\n<\/ol>\n<p>function markAllTrashAsRead() {<\/p>\n<p>var threads = GmailApp.search(&#8216;in:trash label:unread&#8217;);<\/p>\n<p>GmailApp.markThreadsRead(threads);<\/p>\n<p>};<\/p>\n<p>The code will look for threads with the label \u201cin:trash label:unread\u201d. Once the threads have been retrieved the thread messages will be marked as read.<\/p>\n<p>Below is a sample screenshot of the editor window.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"634\" height=\"251\" class=\"wp-image-31\" src=\"https:\/\/www.newbranch.org\/wordpress\/wp-content\/uploads\/2018\/09\/word-image.png\" srcset=\"https:\/\/www.newbranch.org\/wordpress\/wp-content\/uploads\/2018\/09\/word-image.png 634w, https:\/\/www.newbranch.org\/wordpress\/wp-content\/uploads\/2018\/09\/word-image-300x119.png 300w\" sizes=\"auto, (max-width: 634px) 100vw, 634px\" \/><\/p>\n<p><a id=\"post-30-_ccz0o1b606k8\"><\/a><br \/>\nRun and Test the Script<\/p>\n<p>Below are the steps to run and test the script to make sure it\u2019s running correctly.<\/p>\n<ol>\n<li>Run the task by clicking the run button on the toolbar.<\/li>\n<li>Google may then ask for permission for the script to access your GMail account. Accept the permissions and the task should run.<\/li>\n<li>The task should run and finally mark those messages in the Trash folder as read.<\/li>\n<\/ol>\n<p><a id=\"post-30-_oubs6pgcktlu\"><\/a><br \/>\nSet the Timer<\/p>\n<p>The timer is a handy feature to have the script automatically execute on the Google Servers at a specified time interval. No additional windows or web service is needed to execute the script. Below are the steps to set it up.<\/p>\n<ol>\n<li>Click the Timer button.<\/li>\n<li>Below is the screenshot that shows the timer window.<br \/>\n<img loading=\"lazy\" decoding=\"async\" width=\"853\" height=\"262\" class=\"wp-image-32\" src=\"https:\/\/www.newbranch.org\/wordpress\/wp-content\/uploads\/2018\/09\/word-image-1.png\" srcset=\"https:\/\/www.newbranch.org\/wordpress\/wp-content\/uploads\/2018\/09\/word-image-1.png 853w, https:\/\/www.newbranch.org\/wordpress\/wp-content\/uploads\/2018\/09\/word-image-1-300x92.png 300w, https:\/\/www.newbranch.org\/wordpress\/wp-content\/uploads\/2018\/09\/word-image-1-768x236.png 768w\" sizes=\"auto, (max-width: 853px) 100vw, 853px\" \/><\/li>\n<li>You can setup any timer interval like minute, hourly, daily, weekly, etc.<\/li>\n<li>Click the Save button to save the timer.<\/li>\n<\/ol>\n<p><a id=\"post-30-_gyz6x3q0y7d2\"><\/a><br \/>\nOther Sample Scripts<\/p>\n<p>\/\/ delete calendar invite emails older than 14 days.<\/p>\n<p>function moveCalendarMsgsToTrash() {<\/p>\n<p>var threads = GmailApp.search(&#8216;filename:invite.ics older_than:14d&#8217;);<\/p>\n<p>GmailApp.moveThreadsToTrash(threads);<\/p>\n<p>};<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GMail isn\u2019t an Enterprise email client like Microsoft Outlook. It has some gaps. One of those gaps is to automatically mark the messages as Read when they go into the Trash folder. Unfortunately GMail doesn\u2019t natively mark theses messages as read. Thankfully Google has a scripts web site that can accomplish this task. Below are&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-30","post","type-post","status-publish","format-standard","hentry","category-gmail"],"_links":{"self":[{"href":"https:\/\/www.newbranch.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/30","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.newbranch.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.newbranch.org\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.newbranch.org\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.newbranch.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=30"}],"version-history":[{"count":2,"href":"https:\/\/www.newbranch.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/30\/revisions"}],"predecessor-version":[{"id":34,"href":"https:\/\/www.newbranch.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/30\/revisions\/34"}],"wp:attachment":[{"href":"https:\/\/www.newbranch.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=30"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.newbranch.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=30"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.newbranch.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}