Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The only time I get emails with 5+ recipients is when the office gossip is going around. I would love to make a rule/filter to move any incoming message with more than 5 recipients into a junk folder.

Is that possible with Outlook 2010? I could not find anything like that in the default rules, wasn't sure if you could VB the rule. Any insight is appreciated.

share|improve this question
With VBA it should be very much possible. Here's a macro that counts the number of recipients in a mail being sent (Application_ItemSend() event). You should be able to tweak it to run when a mail is received, using either the NewMailEx() or Items.ItemAdd() events as detailed here. – Karan Feb 8 '13 at 3:35

I wrote the VBA script using resources from StackOverflow and SuperUser if anyone is interested.

This script takes all incoming emails and counts the recipients in the To: field,if recipient count is greater than 5, marks it as read, and moves is to a Gossip folder.

There is also a secondary condition to check if subject contains CVS (we get updates from our concurrent version system which has 10 recipients) and move is to the appropriate folder.

Sub moveOfficeGossip(item As Outlook.MailItem)

    Dim strNames As String, i As Integer, j As Integer, cvs As String
    Dim olApp As New Outlook.Application
    Dim olNameSpace As Outlook.NameSpace
    Dim olDestFolder As Outlook.MAPIFolder

    j = 1
    cvs = "CVS"
    strNames = item.To
    Set olNameSpace = olApp.GetNamespace("MAPI")

    For i = 1 To Len(strNames)
        If Mid(strNames, i, 1) = ";" Then j = j + 1
    Next i

    If (j >= 5) Then
        If InStr(UCase(item.subject), cvs) Then
            Set olDestFolder = olNameSpace.Folders("Personal Folders").Folders("Filtered").Folders("CVS")
            item.Move olDestFolder
            Set olDestFolder = olNameSpace.Folders("Personal Folders").Folders("Filtered").Folders("Gossip")
            item.UnRead = False
            item.Move olDestFolder
        End If
    End If

End Sub

I apologize if this is not in the most formal format and I know that it can be organized a bit better, but this was my first attempt at using any Visual Basic syntax.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .