Question : Anti-Spam Plugin (Outlook 2007)

I am looking for an anti-spam Outlook plugin. The program must be able to do the following:

It must ONLY detect spam from words I have entered.
It must automatically delete any emails containing my predefined word list.


If you have any information that could help me in my hunt for a program like this, please respond.

Answer : Anti-Spam Plugin (Outlook 2007)

You're welcome.

Here's the code for this.  It searches both the subject and messages body for the words you specify.  You can use this on as many PCs as you want.

Follow these instructions to use it.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
5.  Edit the code as needed.  I included comment lines wherever something needs to or can change
6.  Click the diskette icon on the toolbar to save the changes
7.  Close the VB Editor
8.  Click Tools > Trust Center
9.  Click Macro Security
10. Set Macro Security to "Warnings for all macros"
11. Click OK
12. Close Outlook
13. Start Outlook.  Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
Dim WithEvents olkInbox As Outlook.Items

Private Sub Application_Quit()
    Set olkInbox = Nothing
End Sub

Private Sub Application_Startup()
    Set olkInbox = Session.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub olkInbox_ItemAdd(ByVal Item As Object)
    If Item.Class = olMail Then
        SpamChecker Item
    End If
End Sub

Sub SpamChecker(Item As Outlook.MailItem)
    'On the next line edit the list of keywords as desired.  Be sure to separate each word with a | character.'
    Const KEYWORDS = "viagra|cialis|prescription|pharmacy|phizer"
    Dim objRegEx As Object, colMatches As Object, bolSpam As Boolean
    Set objRegEx = CreateObject("VBscript.RegExp")
    With objRegEx
        .IgnoreCase = True
        .Pattern = KEYWORDS
        .Global = True
    End With
    Set colMatches = objRegEx.Execute(Item.Subject)
    If colMatches > 0 Then bolSpam = True
    Set colMatches = objRegEx.Execute(Item.Body)
    If colMatches.Count > 0 Then bolSpam = True
    If bolSpam Then Item.Delete
    Set colMatches = Nothing
    Set objRegEx = Nothing
End Sub
Random Solutions  
 
programming4us programming4us