How to easily redirect an email thread in Outlook

Scott Hanselman posted a quick-and-dirty way to disable “Reply To All” and “Forward” (within Outlook, internal users only) for those cases where you just want a reply to yourself.

With the amount of email we get at my company, that’s a pretty useful (and simple!) trick. I used it internally, which of course started a big time-wasting email thread testing it, joking, etc. And it resulted in my friend Scott Bauer creating the “anti-Hanselman” macro–same creation instructions as Hanselman’s, just use this code instead. :)

ActiveInspector.CurrentItem.Actions("Reply to All").Enabled = True
ActiveInspector.CurrentItem.Actions("Forward").Enabled = True

Anyway, it got me thinking about another common scenario we run into frequently. An email gets sent to the wrong distribution list. Doesn’t sound so horrible, does it? But it gets much worse when the email thread goes for a long time and plenty of people who don’t care are on the recipient list. You start getting a few emails like “take me off this thread please”, but most of just keep hitting Delete, and it wastes everybody’s time. (You can’t ignore it because it might be relevant-how can you tell, all you see is a “you’ve got mail” notice, and you don’t want to have to create a rule for every email thread like this.)

Here is how I deal with this scenario:

  1. Forward the email (to maintain attachments, etc.)
  2. Send it TO the original sender and the new (appropriate) distribution list/recipient
  3. Maintain the CC list, as they probably still care
  4. BCC everybody on the original To list
  5. Add a line that says “Forwarding to the appropriate group, BCC’ing everybody else” – or something to that effect
  6. (Here’s the key) Set the “Direct Replies To” field to the new list I’m forwarding to:
    image

By directing replies to the list I’m redirecting to, I effectively take myself out of the loop. Otherwise I unnecessarily sacrifice myself for everybody else by remaining on the irrelevant thread.

Needless to say that gets annoying to do frequently. So, Scott (Hanselman and Bauer) motivated me to create a macro to automate it.

I won’t repeat the details of how to create the macro, and add a button to your message header, etc. Go read Scott Hanselman’s walk-through on how to do that. Then come back here. But just remember to add the macro “toolbar button” to a received message, not a new outgoing message (there is a difference!). I selected the right-arrow-in-a-circle icon for mine (image), sort of indicating a different kind of “forward”.

Now, when I get an email like this:

image

I can click the “Redirect Email” macro and I’m prompted to select some addresses from the address book. After I select them (“Accounting” in this case), I get a new mail, pre-filled out and ready to send.

image

Notice that the “Direct Replies To” button is highlighted (it’s the image of the person with the left-facing purple arrow), indicating that its value is set. Clicking the button shows that it is indeed set:

image

All I have to do is press send. Much easier and much faster than doing all that work by hand.

Paste the following into your macro definition and tweak if you like – I’m not a VB/VBA programmer, so I’m sure it’s not perfect. Post back here if you tweak it and improve it. Also note that I’m including the “Sub” definition, to give my snippet some context. You should already have one created if you follow Scott’s instructions.

Sub RedirectMail()
    Dim mail As MailItem
    Dim forward As MailItem
    Dim recipient As recipient
    Set mail = ActiveInspector.CurrentItem

    Dim selectNamesDlg As SelectNamesDialog
    Set selectNamesDlg = Application.Session.GetSelectNamesDialog
    selectNamesDlg.ForceResolution = True
    If (selectNamesDlg.Display And selectNamesDlg.Recipients.Count > 0) Then

        ' Forward this mail item, initializing the "To" line with:
        ' The original sender of the mail, and the newly selected recipients
        ' Direct replies to the newly selected recipients
        ' People originally on the CC line still get CC'd
        ' Add everybody else on the BCC line

        Set forward = mail.forward

        If (forward.ReplyRecipients.Count > 0) Then
            For i = 1 To forward.ReplyRecipients.Count
                forward.ReplyRecipients.Remove (i)
            Next i
        End If

        forward.Recipients.Add (mail.SenderEmailAddress)

        For Each recipient In selectNamesDlg.Recipients
            forward.Recipients.Add (recipient.Name)
            forward.ReplyRecipients.Add (recipient.Name)
        Next recipient

        For Each recipient In mail.Recipients
            Set theRecipient = forward.Recipients.Add(recipient.Name)
            theRecipient.Type = recipient.Type

            If (recipient.Type <> olCC) Then
                theRecipient.Type = olBCC
            End If
        Next recipient

        If (forward.BodyFormat = olFormatPlain Or olFormatUnspecified) Then
            forward.Body = "Redirecting to the appropriate distribution, and BCC'ing others" + forward.Body
        Else
            forward.HTMLBody = "Redirecting to the appropriate distribution, and BCC'ing others" + forward.HTMLBody
        End If

        forward.Recipients.ResolveAll
        forward.Display

    End If
End Sub

Enjoy!

Update: Lee Holmes posted some good reasons why you shouldn’t use BCC. Please take that into account when using this macro – in my situation, this macro is useful, mostly because of the way my co-workers tend to use email coupled with the size of the distribution lists. It isn’t necessarily a good solution for everybody!

kick it on DotNetKicks.com

This entry was posted on Wednesday, October 24th, 2007 at 4:25 pm and is filed under tips and tricks. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

9 Responses to “How to easily redirect an email thread in Outlook”

  1. Scott Hanselman Says:

    Nicely done!

  2. scauer Says:

    Brilliant idea!

  3. Lee Says:

    Great implementation, but BCCing will get a lot of people angry at you :)

    http://www.leeholmes.com/blog/ThePerilsOfBCC.aspx

  4. scauer Says:

    If getting BCC’d angers you, then clearly you just need better rules. :)

    I have a rule to send all emails to the ‘Bug Reports’ dist list to a subfolder. I have another rule that looks for the text “To: Bug Reports” or “; Bug Reports” which also forwards to that folder, under the assumption that ‘Bug Reports’ has been BCC’d off the email.

  5. JP Says:

    Hey great job on the code, but it only works in Outlook 2007. I adapted your code for OL2003 (should work in OL2000 and 2002 as well). If anyone wants a copy, email me at jp2112 (at) earthlink .dot. net.

    Thx

  6. JP Says:

    Hey folks, I got a few inquiries about the OL2003 code, so I posted it on a new site I just created. Check it out and let me know how it works out for you.

    http://www.codeforexcelandoutlook.com/outlook.html

    Direct Link: http://www.codeforexcelandoutlook.com/RedirectMail.txt

  7. Scott Says:

    I see this in your code:
    If (forward.ReplyRecipients.Count > 0) Then
    For i = 1 To forward.ReplyRecipients.Count
    forward.ReplyRecipients.Remove (i)
    Next i
    End If

    That’s dangerous unless you know exactly how the backend structure works. If you delete item #1, then sometimes you have a hole at item 1, and sometimes item #2 becomes item #1…meaning that there’s no longer an item 2 and you throw an exception when you try to delete #2 as it’s suddenly #1. So you need to reverse your loop and delete from the largest item to the smallest (i.e. delete item #1 last)

    Then you never run into isues.

  8. aaron Says:

    Great point Scott, that would be the right way to do it if you’re not sure what the underlying implementation is, or just want to be safe.

  9. turinmachine Says:

    Thanks a lot from your code! I modifiy it in order to forward to any person included in the “To” field of the original message. Now my Oracle database can send email to one account who forwards the email to any specific account. That’s exactly what I need it.