How do I base an outlook rule on the number of "To:" addresses?

7

1

I would like to create an Outlook rule that stops me from sending out emails that have more than ten email addresses in the "To:" line. Is this even possible? I'm using Outlook 2010 on Windows 7 64-bit.

My reasoning: I send out a distribution letter to a large number of addresses. I usually send this email to myself with the distribution list addresses in the "BCC:" line. Every once in a while I mess up and accidentally put the distribution list addresses on the "To:" line instead. This is a problem because then each email recipient will see all the addresses on the list. I want Outlook to stop me from doing this, or at least warn me before I send it out.

I also welcome suggestions on how to get around this problem.

Erick

Posted 2012-07-06T19:40:28.880

Reputation: 71

Answers

4

There's no built-in way to do this, but you can achieve it with a macro.

Steps1:

  1. In Outlook, press Alt + F11 to open Microsoft Visual Basic.

  2. On the left side of the screen, expand the folder called Microsoft Office Outlook and double-click ThisOutlookSession.2

  3. In the window VbaProject.OTM - TheOutlookSession, select Application in the left and ItemSend in the right drop-down menu.2

  4. Replace the code that apperaed in the window's body by the following:

    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
        Dim Recipients As Integer
        Dim Start As Integer
        Dim Last As Integer
        Recipients = 1
        Do
            Start = Last + 1
            Last = InStr(Start, Item.To, ";")
            If Last = 0 Then Exit Do
            Recipients = Recipients + 1
        Loop
        If (Recipients > 10) Then
            Cancel = (MsgBox(Str(Recipients) & " recipients in To field.", vbOKCancel) = vbCancel)
        End If
    End Sub
    
  5. Press Ctrl + S to save.

  6. Press Alt + Q to return to Outlook.

This macro will display a warning if there are more than 10 recipients in the To field (based on the number of semicolons used to delimit the recipients). You can click OK to dismiss the warning or Cancel to abort.3


1 I'm using Outlook 2007 (in Spanish). I hope Outlook 2010 is similar.

2
screenshot

3
screenshot

Dennis

Posted 2012-07-06T19:40:28.880

Reputation: 42 934

1

Unfortunately, this is not possible with Outlook. While you can use third-party solutions to limit it (i.e., Thunderbird), you lose the functionality of Outlook itself. This is actually a great question, though, and I would love to see Microsoft provide a little better control over what you can and can't send out!

Andrew M.

Posted 2012-07-06T19:40:28.880

Reputation: 244

I was afraid of that. Thank you for answering. – Erick – 2012-07-06T20:15:49.353

No problem; I can't count the number of times I have done exactly what you're trying to prevent yourself from doing. It's too bad the rules aren't more flexible! – Andrew M. – 2012-07-06T20:39:00.227

0

I took Sudo's answer and made it count the recipients in CC and BCC as well, just In case anyone wants it:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim Recipients As Integer
    Dim Start As Integer
    Dim Last As Integer
    Dim RecipientFields As String
    Recipients = 1

    RecipientFields = Item.To

    If (Item.CC <> "") Then
        RecipientFields = RecipientFields + ";" + Item.CC
    End If

    If (Item.BCC <> "") Then
        RecipientFields = RecipientFields + ";" + Item.BCC
    End If

    Do
        Start = Last + 1
        Last = InStr(Start, RecipientFields, ";")
        If Last = 0 Then Exit Do
        Recipients = Recipients + 1
    Loop

    If (Recipients > 6) Then
        Cancel = (MsgBox("You have " & Str(Recipients) & " recipients in To/CC/BCC fields.  Click OK to send.", vbOKCancel) = vbCancel)
    End If
End Sub

Rudy Scoggins

Posted 2012-07-06T19:40:28.880

Reputation: 1