---
title: "A highly primitive solution for fighting .Text blog spam - an outlook script"
url: "https://osherove.com/blog/2004/12/15/a-highly-primitive-solution-for-fighting-text-blog-spam-an-o.md"
canonical: "https://osherove.com/blog/2004/12/15/a-highly-primitive-solution-for-fighting-text-blog-spam-an-o.html"
published: "2004-12-15T21:13:00"
updated: "2004-12-15T21:13:00"
tags: ["Blogging"]
author: "Roy Osherove"
description: "A few days ago I opened my machine and saw that I had 348 new spam comments on my blog. Now, .Text is now smart enough to provide a link for you in the notification email that allows you to \"hide\" each comment via one…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# A highly primitive solution for fighting .Text blog spam - an outlook script

By Roy Osherove December 15, 2004 In [Blogging](https://osherove.com/blog/category/blogging)

**Historical article** · Originally published December 15, 2004; technical details may be outdated.

A few days ago I opened my machine and saw that I had 348 new spam comments on my blog.

Now, .Text is now smart enough to provide a link for you in the notification email that allows you to "hide" each comment via one click, but when it comes to doing this same thing 350 times it becomes - well, not so effective.

So I created a simple solution to my problem.

I created a simple VBA script that runs inside outlook. Whenever a new email arrives, it checks whether it is a blog comment, and if so, if it comes from a specific IP that you have specified as "banned". if it does, than it will automatically find the entry ID inside the email body, and execute the link that hides the comment for you inside the default browser. Simple, but it works.

[Here's the file that contains all the script](https://osherove.com/LinkClick.aspx?link=http%3a%2f%2fosherove.com%2fdownloads%2foutlookIpBanScript.zip&mid=347).

It comes with comments inside it that explain exactly what you need to do to make it work for your own blog (you basically need to just change a couple of string on the top, and add simple lines for each IP address you would like to ban). It works on Office 2003 (uses the Application\_NewEmailEx event which is only available in that version..) cause that what I have. I'm sure this can be implemented for working in older version too.

Currently this just works on new email. I should add another ability that cleans out existing spam too. Should not be too hard to implement. Will post more when there is more to tell...

Hope this helps!

\[update:\]

Add the following function to the file and you have a macro that allows you to look at existing folders for comment spam. It lets you select a folder and applies the same rules on unread emails inside it:

**Public Sub SearchEmailsForCommentSpam()**

Dim oNS As NameSpace
Dim counter As Integer

Set oNS = Application.GetNamespace("MAPI")
Dim oFolder As MAPIFolder
Set oFolder = oNS.PickFolder

Dim oMessage As MailItem
Dim bannedIds As Collection
Set bannedIds = GetBannedIPAddresses()

For Each oMessage In oFolder.Items
    If oMessage.UnRead = True Then
        If HandleMailIfIsValidCommentSpam(oMessage, bannedIds) Then
            counter = counter + 1
        End If
    End If
Next oMessage

MsgBox "Took care of " & counter & " blog spam items!"

End Sub

**Private Function HandleMailIfIsValidCommentSpam(mail As MailItem, varBannedIds As Collection) As Boolean**
          If IsMailABlogComment(mail) Then
                If IsMailFromBannedIP(mail, varBannedIds) Then
                    Call DisableCommentInMailByClickingLink(mail)
                    HandleMailIfIsValidCommentSpam = True
                    Exit Function
                End If
          End If
          HandleMailIfIsValidCommentSpam = False
End Function

**update:**

Well, this sucks!

I can't get shellexecute to actually "hide" the link. When I open the required "remove" link in the browser it simply shows the list of comments , but does not actually remove any of them. HOWEVER, if I actually CLICK on the mail message link, (which points to the SAME link exactly) the message will be hidden. Any idea what's going on here?

## More in Blogging

[All posts in Blogging](https://osherove.com/blog/category/blogging)

- Dec 31, 2004

    ### [\[OT\] Some free time coming soon](https://osherove.com/blog/2004/12/31/ot-some-free-time-coming-soon.html)

- Dec 31, 2004

    ### [Is PostXing gonna solve my blogging needs?](https://osherove.com/blog/2004/12/31/is-postxing-gonna-solve-my-blogging-needs.html)

- Dec 5, 2004

    ### [Blogger dinner with Johanna Rothman - Rescheduled](https://osherove.com/blog/2004/12/5/blogger-dinner-with-johanna-rothman-rescheduled.html)

- Dec 2, 2004

    ### [This Tuesday is Israel Geek Dinner Day with Johanna Rothman](https://osherove.com/blog/2004/12/2/this-tuesday-is-israel-geek-dinner-day-with-johanna-rothman.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
