How to set automatic BCC when body has specific “STRING” RRS feed

  • Question

  • Hi,

    How can I make a script that runs whenever I reply/forward email with specific "STRING" in body and set email address in BCC?

    Thank you!

    Tuesday, May 19, 2015 8:15 PM

All replies

  • Put the following macro in the ThisOutlookSession module. If the STRING is present anywhere in in the body of the message then the address defined as strAddress is added as BCC. Note that 'STRING' is case sensitive.

    Option Explicit
    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim olRecipient As Outlook.Recipient
    Const strAddress As String = ""
    Const strText As String = "STRING"
        If InStr(1, Item.Body, strText) > 0 Then
            Set olRecipient = Item.Recipients.Add(strAddress)
            olRecipient.Type = olBCC
        End If
        Set olRecipient = Nothing
        Exit Sub
    End Sub

    Graham Mayor - Word MVP

    Wednesday, May 20, 2015 6:01 AM