{"id":1320,"date":"2026-03-01T08:05:00","date_gmt":"2026-03-01T14:05:00","guid":{"rendered":"http:\/\/www.internaldiscourses.com\/?p=1320"},"modified":"2026-03-10T08:42:58","modified_gmt":"2026-03-10T13:42:58","slug":"spam-email-filtering-part-2","status":"publish","type":"post","link":"https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-2\/","title":{"rendered":"Spam Email Filtering &#8211; Part 2"},"content":{"rendered":"\n<p>This is a follow up to the initial <a href=\"https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-1\/\">Spam Email Filtering &#8211; Part 1<\/a> post. It has been a little over a month since I first developed the functionality and I&#8217;ve been very happy with the results. Since then, I&#8217;ve made a few tweaks to it. The download links in both the initial post and this one are to the same files so it doesn&#8217;t matter from which post you download them as they are the latest version.<\/p>\n\n\n\n<p>Updates:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Added <strong>PurgeDeletedItems()<\/strong> &#8211; this only deletes spam emails from the Deleted Items email folder. This was added because when spam is detected in the Inbox, it is moved to the Deleted Items email folder. Normally, email stays in this folder for 30 days before Outlook will automatically delete it. Since we are managing known spam, why let it sit for 30 days?<\/li>\n\n\n\n<li>Added <strong>MoveJunk2Inbox()<\/strong> &#8211; this was added to optimize the spam filtering process and eliminate the need to manually manage the Junk email folder. This is also helpful when Outlook inadvertently sends legitimate email to the Junk folder; the function moves anything sent to the Junk folder back to the Inbox.<\/li>\n\n\n\n<li>Updated <strong>ThisOutlookSession<\/strong> macro to call the <strong>MoveJunk2Inbox()<\/strong> process to automate the management of the Junk email folder.<\/li>\n<\/ul>\n\n\n<p>The below text file contains the known spam domains and has been updated since the initial version. The list of known spam domains will grow as you identify new spam email and place them in the BadEmail folder. See part 1 for more details. <div class=\"sdm_download_button_box_default\"><div class=\"sdm_download_link\"><a href=\"https:\/\/www.internaldiscourses.com\/?sdm_process_download=1&download_id=1297\" class=\"sdm_download green\" title=\"Spam Domains List\" target=&quot;_blank&quot;>spamDomainsList.txt<\/a><\/div><\/div><\/p>\n\n\n<p>Current version of all the spam filtering functionality. <div class=\"sdm_download_button_box_default\"><div class=\"sdm_download_link\"><a href=\"https:\/\/www.internaldiscourses.com\/?sdm_process_download=1&download_id=1284\" class=\"sdm_download green\" title=\"Spam Filter Macro\" target=&quot;_blank&quot;>spamFilter.txt<\/a><\/div><\/div><\/p>\n\n\n<p>Current version that automatically moves email from the Junk folder and runs the spam filtering process when new email arrives in the Inbox. <div class=\"sdm_download_button_box_default\"><div class=\"sdm_download_link\"><a href=\"https:\/\/www.internaldiscourses.com\/?sdm_process_download=1&download_id=1288\" class=\"sdm_download green\" title=\"Automate Inbox Checking\" target=&quot;_blank&quot;>ThisOutlookSession.txt<\/a><\/div><\/div><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Recap Of The Setup Process<\/h4>\n\n\n\n<p><strong>Step 1<\/strong> &#8211; Create a folder on the C: drive named <strong>_spam_domains<\/strong> and place the downloaded spamDomainsList.txt file in this location; the spam filter macro expects to find the text file at this location. You can use a different location and rename the file if you like, but if you do, you&#8217;ll need to edit the macro every place that references the default values.<\/p>\n\n\n\n<p><strong>Step 2<\/strong> &#8211; Select the Developer menu option from the top menu bar of Outlook. If you don&#8217;t see it, a quick Google search will explain how to enable and display that feature. Selecting the Developer menu option will open the Visual Basic interface which allows you to create and manage macros. Create a new module and then copy\/paste the contents from the spamFilter.txt file you downloaded and save. Once this step is completed, you have everything needed to manually manage spam email.<\/p>\n\n\n\n<p><strong>Step 3<\/strong> &#8211; To automate the filtering process, select the Developer menu option (if not already open) and select &#8216;Visual Basic&#8217; to open the macro editor. Next, double-click the ThisOutlookSession to open the editor panel. Then copy\/paste the contents of the ThisOutlookSession.txt file you downloaded and save. Finally, close Outlook and reopen it and the macros will now automatically process spam email as it arrives.<\/p>\n\n\n\n<p>For a more detailed explanation of the setup steps, refer to the <a href=\"https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-1\/\" data-type=\"link\" data-id=\"https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-1\/\">Spam Email Filtering &#8211; Part 1<\/a> post.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Helpful Notes<\/h4>\n\n\n\n<p>The spam filtering process only runs if Outlook is open. If you close Outlook, any received spam email will be in your Inbox until you either receive a new email or manually run the macro.<\/p>\n\n\n\n<p>The filtering process only applies to emails that are Unread. If you view a suspected spam email and the status changes to Read, the spam filter will ignore it unless you change the status back to Unread.<\/p>\n\n\n\n<p>In the <strong>ProcessBadEmailFolder()<\/strong> process, make sure to update the following line with your actual email address: <\/p>\n\n\n\n<p>Set badFolder = olNs.Folders(&#8220;<strong>your_Outlook_email<\/strong>&#8220;).Folders(&#8220;BadEmail&#8221;) &#8216; Replace your_Outlook_email with your actual Outlook email address.<\/p>\n\n\n\n<p>In the event you accidentally placed a &#8220;good&#8221; email in the BadEmail folder and it gets added to the spamDomainsList.txt file, you can remove it. Simply open the text file and delete the domain you don&#8217;t want filtered and save the file. It&#8217;s that simple.<\/p>\n\n\n\n<p>The <strong>PurgeDeletedItems()<\/strong> can be disabled if you don&#8217;t want spam emails to be automatically deleted. When new email arrives, if the spam filter identifies it as spam it moves the email to the Deleted Items email folder. After all Unread emails in the Inbox have been processed and the <strong>ProcessBadEmailFolder()<\/strong> process has run, the <strong>PurgeDeletedItems()<\/strong> process then runs. It will only delete Unread spam email found in the spamDomainsList.txt file. If you want to disable this process, comment out the <strong>Call PurgeDeletedItems<\/strong> statement in the macro module that was copied from the spamFilter.txt file.<\/p>\n\n\n\n<p>In Outlook, you can customize the Quick Access menu bar by adding mini icons to specific processes of the spam filter macro. I created one that calls the <strong>CheckInbox()<\/strong> process which runs the complete spam filter routine and displays a confirmation when done. I&#8217;ll occasionally use it if I want to immediately run the process to add new spam emails that I placed in the BadEmail folder. The second one I created calls the <strong>CountSpamDomains()<\/strong> that is only for informational purposes and displays a message box with the total number of spam domains contained in the spamDomainsList.txt file. The list will grow over time as you identify new spam and place them in the BadEmail folder.<\/p>\n\n\n\n<p>Let me know if you find this useful or think of something that could be added to it. Enjoy&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a follow up to the initial Spam Email Filtering &#8211; Part 1 post. It has been a little over a month since I first developed the functionality and I&#8217;ve been very happy with the results. Since then, I&#8217;ve made a few tweaks to it. The download links in both the initial post and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[152],"tags":[9,177,182,184,181,175,176,180,183,178,185,179],"class_list":["post-1320","post","type-post","status-publish","format-standard","hentry","category-technology","tag-automation","tag-email","tag-junk-mail","tag-macro","tag-microsoft","tag-outlook","tag-spam","tag-spam-filter","tag-spam-macro","tag-vb","tag-vb-macro","tag-visual-basic"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\r\n<title>Spam Email Filtering - Part 2 - Internal Discourses<\/title>\r\n<meta name=\"description\" content=\"A collection of random topics and thoughts - Life Experiences, Parenting, Philosophical Thoughts, Technology\" \/>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-2\/\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"Spam Email Filtering - Part 2 - Internal Discourses\" \/>\r\n<meta property=\"og:description\" content=\"A collection of random topics and thoughts - Life Experiences, Parenting, Philosophical Thoughts, Technology\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-2\/\" \/>\r\n<meta property=\"og:site_name\" content=\"Internal Discourses\" \/>\r\n<meta property=\"article:published_time\" content=\"2026-03-01T14:05:00+00:00\" \/>\r\n<meta property=\"article:modified_time\" content=\"2026-03-10T13:42:58+00:00\" \/>\r\n<meta name=\"author\" content=\"nom de guerre\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"nom de guerre\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.internaldiscourses.com\\\/index.php\\\/spam-email-filtering-part-2\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.internaldiscourses.com\\\/index.php\\\/spam-email-filtering-part-2\\\/\"},\"author\":{\"name\":\"nom de guerre\",\"@id\":\"https:\\\/\\\/www.internaldiscourses.com\\\/#\\\/schema\\\/person\\\/3bd35f648a2c7d17352ed763bcb6208a\"},\"headline\":\"Spam Email Filtering &#8211; Part 2\",\"datePublished\":\"2026-03-01T14:05:00+00:00\",\"dateModified\":\"2026-03-10T13:42:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.internaldiscourses.com\\\/index.php\\\/spam-email-filtering-part-2\\\/\"},\"wordCount\":932,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.internaldiscourses.com\\\/#\\\/schema\\\/person\\\/3bd35f648a2c7d17352ed763bcb6208a\"},\"keywords\":[\"Automation\",\"Email\",\"Junk Mail\",\"Macro\",\"Microsoft\",\"Outlook\",\"Spam\",\"Spam Filter\",\"Spam Macro\",\"VB\",\"VB Macro\",\"Visual Basic\"],\"articleSection\":[\"Technology\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.internaldiscourses.com\\\/index.php\\\/spam-email-filtering-part-2\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.internaldiscourses.com\\\/index.php\\\/spam-email-filtering-part-2\\\/\",\"url\":\"https:\\\/\\\/www.internaldiscourses.com\\\/index.php\\\/spam-email-filtering-part-2\\\/\",\"name\":\"Spam Email Filtering - Part 2 - Internal Discourses\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.internaldiscourses.com\\\/#website\"},\"datePublished\":\"2026-03-01T14:05:00+00:00\",\"dateModified\":\"2026-03-10T13:42:58+00:00\",\"description\":\"A collection of random topics and thoughts - Life Experiences, Parenting, Philosophical Thoughts, Technology\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.internaldiscourses.com\\\/index.php\\\/spam-email-filtering-part-2\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.internaldiscourses.com\\\/index.php\\\/spam-email-filtering-part-2\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.internaldiscourses.com\\\/index.php\\\/spam-email-filtering-part-2\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.internaldiscourses.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spam Email Filtering &#8211; Part 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.internaldiscourses.com\\\/#website\",\"url\":\"https:\\\/\\\/www.internaldiscourses.com\\\/\",\"name\":\"Internal Discourses\",\"description\":\"A collection of random topics and thoughts\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.internaldiscourses.com\\\/#\\\/schema\\\/person\\\/3bd35f648a2c7d17352ed763bcb6208a\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.internaldiscourses.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.internaldiscourses.com\\\/#\\\/schema\\\/person\\\/3bd35f648a2c7d17352ed763bcb6208a\",\"name\":\"nom de guerre\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.internaldiscourses.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/discourses_logo.jpg\",\"url\":\"https:\\\/\\\/www.internaldiscourses.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/discourses_logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.internaldiscourses.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/discourses_logo.jpg\",\"width\":294,\"height\":294,\"caption\":\"nom de guerre\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.internaldiscourses.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/discourses_logo.jpg\"},\"sameAs\":[\"https:\\\/\\\/www.internaldiscourses.com\"],\"url\":\"https:\\\/\\\/www.internaldiscourses.com\\\/index.php\\\/author\\\/nom-de-guerre\\\/\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spam Email Filtering - Part 2 - Internal Discourses","description":"A collection of random topics and thoughts - Life Experiences, Parenting, Philosophical Thoughts, Technology","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-2\/","og_locale":"en_US","og_type":"article","og_title":"Spam Email Filtering - Part 2 - Internal Discourses","og_description":"A collection of random topics and thoughts - Life Experiences, Parenting, Philosophical Thoughts, Technology","og_url":"https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-2\/","og_site_name":"Internal Discourses","article_published_time":"2026-03-01T14:05:00+00:00","article_modified_time":"2026-03-10T13:42:58+00:00","author":"nom de guerre","twitter_card":"summary_large_image","twitter_misc":{"Written by":"nom de guerre","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-2\/#article","isPartOf":{"@id":"https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-2\/"},"author":{"name":"nom de guerre","@id":"https:\/\/www.internaldiscourses.com\/#\/schema\/person\/3bd35f648a2c7d17352ed763bcb6208a"},"headline":"Spam Email Filtering &#8211; Part 2","datePublished":"2026-03-01T14:05:00+00:00","dateModified":"2026-03-10T13:42:58+00:00","mainEntityOfPage":{"@id":"https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-2\/"},"wordCount":932,"commentCount":0,"publisher":{"@id":"https:\/\/www.internaldiscourses.com\/#\/schema\/person\/3bd35f648a2c7d17352ed763bcb6208a"},"keywords":["Automation","Email","Junk Mail","Macro","Microsoft","Outlook","Spam","Spam Filter","Spam Macro","VB","VB Macro","Visual Basic"],"articleSection":["Technology"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-2\/","url":"https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-2\/","name":"Spam Email Filtering - Part 2 - Internal Discourses","isPartOf":{"@id":"https:\/\/www.internaldiscourses.com\/#website"},"datePublished":"2026-03-01T14:05:00+00:00","dateModified":"2026-03-10T13:42:58+00:00","description":"A collection of random topics and thoughts - Life Experiences, Parenting, Philosophical Thoughts, Technology","breadcrumb":{"@id":"https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.internaldiscourses.com\/index.php\/spam-email-filtering-part-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.internaldiscourses.com\/"},{"@type":"ListItem","position":2,"name":"Spam Email Filtering &#8211; Part 2"}]},{"@type":"WebSite","@id":"https:\/\/www.internaldiscourses.com\/#website","url":"https:\/\/www.internaldiscourses.com\/","name":"Internal Discourses","description":"A collection of random topics and thoughts","publisher":{"@id":"https:\/\/www.internaldiscourses.com\/#\/schema\/person\/3bd35f648a2c7d17352ed763bcb6208a"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.internaldiscourses.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.internaldiscourses.com\/#\/schema\/person\/3bd35f648a2c7d17352ed763bcb6208a","name":"nom de guerre","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.internaldiscourses.com\/wp-content\/uploads\/2023\/12\/discourses_logo.jpg","url":"https:\/\/www.internaldiscourses.com\/wp-content\/uploads\/2023\/12\/discourses_logo.jpg","contentUrl":"https:\/\/www.internaldiscourses.com\/wp-content\/uploads\/2023\/12\/discourses_logo.jpg","width":294,"height":294,"caption":"nom de guerre"},"logo":{"@id":"https:\/\/www.internaldiscourses.com\/wp-content\/uploads\/2023\/12\/discourses_logo.jpg"},"sameAs":["https:\/\/www.internaldiscourses.com"],"url":"https:\/\/www.internaldiscourses.com\/index.php\/author\/nom-de-guerre\/"}]}},"_links":{"self":[{"href":"https:\/\/www.internaldiscourses.com\/index.php\/wp-json\/wp\/v2\/posts\/1320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.internaldiscourses.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.internaldiscourses.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.internaldiscourses.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.internaldiscourses.com\/index.php\/wp-json\/wp\/v2\/comments?post=1320"}],"version-history":[{"count":44,"href":"https:\/\/www.internaldiscourses.com\/index.php\/wp-json\/wp\/v2\/posts\/1320\/revisions"}],"predecessor-version":[{"id":1445,"href":"https:\/\/www.internaldiscourses.com\/index.php\/wp-json\/wp\/v2\/posts\/1320\/revisions\/1445"}],"wp:attachment":[{"href":"https:\/\/www.internaldiscourses.com\/index.php\/wp-json\/wp\/v2\/media?parent=1320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.internaldiscourses.com\/index.php\/wp-json\/wp\/v2\/categories?post=1320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.internaldiscourses.com\/index.php\/wp-json\/wp\/v2\/tags?post=1320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}