Block Sender for Multiple Senders – Outlook spam

5 pts.
Tags:
Exchange 2010
Exchange spam filters
Microsoft Outlook 2010
Spam filters
I get a lot of junk e-mail. I was out sick for a week and have almost 2000 messages of which 99% are junk. However, Outlook will only let me block sender one at a time. This is going to take a week while more junk keeps piling in.

Software/Hardware used:
Outlook 2010

Answer Wiki

Thanks. We'll let you know when a new response is added.

Just delete the email. It seams like you need to get a better SPAM filter on your mail server so that the bulk of that will all be caught long before it gets to you.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Technochic
    I agree with Mr Denny. Try contacting your Exchange Administrator to find out what they can do to hellp you get the SPAM blocked. This should be done before it hits your mailbox.
    57,010 pointsBadges:
    report
  • QSolAG
    Finally worked out VBA to block multiple senders. This works best when you have a local install of Outlook (so not Exchange).
    Our friends at Microsoft do not expose ANY useful methods for Junk function, which means I have had to drive the GUI the hard way.
    With SendKeys. So not pretty. But I got it working for me.
    You just need to import the below code, and then link a Quick Access Toolbar item to it.
    -------------------
    Option Explicit
    'Limit number of lines from top to check ...
    Const MaxLines = 100
    Public Sub Junk_Item()
        '(C) Quatro Solutions, 2018
        'www.quatrosolutions.co.uk
       
        On Error GoTo FAIL
       
        Dim Session As Outlook.NameSpace
        Dim CurrentExplorer As Explorer
        Dim Selection As Selection
        Dim ItemSubject As String
        Dim ItemSubjects As New Collection
        Dim ItemNo As Integer
      
        Dim JunkItem As Outlook.MailItem

        Set CurrentExplorer = Application.ActiveExplorer
        Set Selection = CurrentExplorer.Selection
        Select Case Selection.Count
        Case 1      'Single item select is straightforward
            'MsgBox "Junking single item."
            SendKeys "%HJB^{HOME}", True
            Exit Sub
        Case Is > 1
            For Each JunkItem In Selection
                'MsgBox "Junking item " & JunkItem.Subject & " from " & JunkItem.SenderEmailAddress, vbOKOnly, "SpamFilter"
                ItemSubjects.Add JunkItem.EntryID, JunkItem.EntryID
            Next
        Case Else
        End Select
          
        Select Case MsgBox("Do you wish to mark these " & Str(ItemSubjects.Count) & " items as Spam?", vbOKCancel, "SpamFilter")
        Case vbOK
        Case Else
            Exit Sub
        End Select
       
        'Now loads of SendKeys because stupid Outlook VBA doesn't expose the methods necessary to Junk selected items,
        'or even ability to highlight specific items in the GUI by EntryID so we can send a simple "+HJB" for each one
        
         'Go to top of list
        SendKeys "{HOME}", True
        DoEvents
       
        Select Case CurrentExplorer.Selection.Count
        Case 0
            MsgBox "No item selected"
        Case 1
            ItemSubject = ""
            For ItemNo = 1 To MaxLines
                'Select current line
                Set Selection = CurrentExplorer.Selection
                For Each JunkItem In Selection
                    'Check if we got 'stuck' on last item
                    If ItemSubject = JunkItem.EntryID Then SendKeys "{Down}"
                    If IsInCollection(JunkItem.EntryID, ItemSubjects) Then
                        'MsgBox "Junking item " & JunkItem.Subject & " from " & JunkItem.SenderEmailAddress
                        ItemSubject = JunkItem.EntryID
                        SendKeys "+{F10}", True
                        SendKeys "J", True
                        SendKeys "B", True
                        DoEvents
                        'Remove Item from Collection
                        ItemSubjects.Remove ItemSubject
                        If ItemSubjects.Count = 0 Then GoTo ENDSUB
                    Else
                        SendKeys "{DOWN}", True
                        DoEvents
                    End If
                Next
            Next
        Case Else
            MsgBox "Multiple items still selected. Junk will not work on multiple items.", vbOKOnly, "SpamFilter"
        End Select
       
       
    ENDSUB:
        'Now keep going to the end
        On Error Resume Next
       
        Set Session = Nothing
        Set CurrentExplorer = Nothing
        Set JunkItem = Nothing
        Set Selection = Nothing
        Set ItemSubjects = Nothing
       
        SendKeys "{HOME}", True
        DoEvents
           
        Exit Sub
    FAIL:
        MsgBox "Junk item failed: " & Error, vbOKOnly, "SpamFilter"
       
       
    End Sub
    Private Function IsInCollection(key As String, arr As Collection) As Boolean
        Dim obj As Variant
        On Error GoTo FAIL
        IsInCollection = True
        obj = arr(key)
        Exit Function
    FAIL:
        IsInCollection = False
    End Function
    Public Sub CheckForSpam()
        On Error GoTo FAIL
       
        Dim Session As Outlook.NameSpace
        Dim CurrentExplorer As Explorer
        Dim Selection As Selection
        Dim ItemNo As Integer
        Dim Spin As Integer
        Dim ItemSubject As String
        Dim ItemSubjects() As String
      
        Dim JunkItem As Outlook.MailItem
        Set CurrentExplorer = Application.ActiveExplorer
        Set Selection = CurrentExplorer.Selection
       
        For Each JunkItem In Selection
            Find_Spam JunkItem
        Next JunkItem
       
        Exit Sub
    FAIL:
        MsgBox "Scan for spam failed.", vbOKOnly, "SpamFilter"
        Exit Sub
    End Sub
    30 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: