I found a script on ExtendOffice.com that does this perfectly, except the BCC email address isn't displayed in the field. The value is there, but invisible (as it does indeed work). I want to alter the following code so that the auto-BCC email will be visible in the field when writing an email, for exceptional cases where I don't want to BCC anybody, so that it can be removed.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim objRecip As Recipient
    Dim strMsg As String
    Dim res As Integer
    Dim strBcc As String
    On Error Resume Next

    ' #### USER OPTIONS ####
    ' address for Bcc -- must be SMTP address or resolvable
    ' to a name in the address book
    strBcc = "email@address.com"

    Set objRecip = Item.Recipients.Add(strBcc)
    objRecip.Type = olBCC
    If Not objRecip.Resolve Then
        strMsg = "Could not resolve the Bcc recipient. " & _
                "Do you want still to send the message?"
        res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
                "Could Not Resolve Bcc Recipient")
        If res = vbNo Then
            Cancel = True
        End If
    End If

    Set objRecip = Nothing
End Sub

Any takers?

Recommended Answers

All 5 Replies

I see there has been no help so I'm wondering if you've had any success with this on your own?

Try This

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

    Dim objRecip As Recipient
    Dim strMsg As String
    Dim res As Integer
    Dim strBcc As String
'ADDED LINES *********
    Dim nameSel As Outlook.SelectNamesDialog
'ADDED LINES *********

    On Error Resume Next

    ' #### USER OPTIONS ####
    ' address for Bcc -- must be SMTP address or resolvable
    ' to a name in the address book
'ADDED LINES *********
    Set nameSel = Session.GetSelectNamesDialog
    nameSel.AllowMultipleSelection = False
    nameSel.NumberOfRecipientSelectors = olShowToCcBcc
'ADDED LINES *********

    strBcc = "email@address.com"
    Set objRecip = Item.Recipients.Add(strBcc)
    objRecip.Type = olBCC
    If Not objRecip.Resolve Then
        strMsg = "Could not resolve the Bcc recipient. " & _
                 "Do you want still to send the message?"
        res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
              "Could Not Resolve Bcc Recipient")
        If res = vbNo Then
            Cancel = True
        End If
    End If
    Set objRecip = Nothing
    Set nameSel = Nothing

End Sub

aktharshaik,

Thank you for the suggestion. However when I try with your added lines it doesn't work, period.

I wonder if it would work rearranged? I don't know enough about VB or Outlook API to really know jack at a glance. Just a hopeful hunch. I'll look into the lines you added and what they do exactly, how they work, and the rest of the code, and try to figure it out and get back.

Oh. I just realized something that voids this whole mission:

The code runs on ItemSend -- not before sending. Can't display anything for you prior to sending.

Am I right? Shouldn't it be changed to Application_ItemLoad? Somebody who knows this stuff please clarify... Thank you.

To auto-populate the BCC field in Outlook, we will create an e-mail template, and create a button that uses a macro to open the e-mail template.

Enable Developer options
  1. Open Outlook
  2. Select "File"
  3. Select "Options"
  4. Click "Customize Ribbon"
  5. In the right-pane, select the "Developer" checkbox
  6. Click "OK"
Create a new e-mail template:
  1. Click "Home" tab
  2. Click "New E-mail"
  3. Customize your e-mail as desired with recipients ("To", "BCC", etc)
  4. Select "File"
  5. Select "Save As"
  6. Change "Save as type" to "Outlook Template (.oft)"
  7. Change "File name" to your desired filename.
  8. Click "Save" (Default will save to %AppData%MicrosoftTemplates)
Create Macro:
  1. On the "Developer" tab, select "Macros",
  2. Select "Macros"
  3. For "Macro Name:", erase any contents and type what you want to call your macro (ex: BccEmail)
  4. Click "Create"

You will see the following:

Sub BccEmail()

End Sub

Copy the code below:

Dim userPath As String
Dim myPath As String

'used to get environment variables found by typing "set" in a cmd window
userPath = Environ("AppData")

myPath = userPath & "MicrosoftTemplatesdefault.oft"
Set msg = Application.CreateItemFromTemplate(myPath)
msg.Display

It should now look like:

Sub BccEmail()
  Dim userPath As String
  Dim myPath As String

  'used to get environment variables found by typing "set" in a cmd window
  userPath = Environ("AppData")

  myPath = userPath & "MicrosoftTemplatesdefault.oft"
  Set msg = Application.CreateItemFromTemplate(myPath)
  msg.Display
End Sub
  1. Click "File"
  2. Select "Save VbaProject.OTM"
  3. Select "Close and Return to Microsoft Outlook"
Create either a Quick Access button or a toolbar group / menu item for your macro:
  1. Select "File"
  2. Select "Options"
  3. Click either "Customize Ribbon" or "Quick Access Toolbar"
Quick Access Toolbar:
  • Under "Choose commands from", select "Macros"
  • Select your newly created macro (ex: BccEmail)
  • To modify the icon, click "Modify" underneath right-pane
Customize Ribbon:
Option 1 (Create new group under existing tab):
  • In right-pane, right-click "Home(Mail)". Right-click on "New" and select "Add New Group".

  • Right-click on "New Group", and select "Rename". Select an icon that you would like and a "Display name" (ex: NewBcc). Click "OK".

  • Under "Choose commands from", select "Macros"

  • Select your newly created macro (ex: BccEmail)

  • In the right-pane, select "NewBcc(Custom) under "Home (Mail)"--or whatever you choose to put it.

  • To change the icon, or rename the macro on the ribbon, right click it, and select "Rename". Click "OK".

Option 2 (Create new tab):
  • Underneath the right-pane, click "New Tab". This will create a new tab in the right-pane. Right-click "New Tab" and select "Rename". Rename it (ex: BccEmail). Click "OK".

  • Right-click on "New Group", and select "Rename". Select an icon that you would like and a "Display name" (ex: New). Click "OK".

  • Under "Choose commands from", select "Macros"

  • Select your newly created macro (ex: BccEmail)

  • In the right-pane, select "New(Custom) under "BccEmail(Custom)"--or whatever you named your new tab.

  • To change the icon, or rename the macro on the ribbon, right click it, and select "Rename"

Click "OK" (lower left corner of window)

Note: For "Macro Security", select "Developer" tab. Click "Macro Security". Click "Macro Settings". Select desired security level.

The above was taken from
here but I slightly modified it. Another resouce can be found here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.