0

I want to autofill the BCC field with a specific address on replies, forwards and new emails.

I have seen a similar function that performs "silently" - i.e., the BCC address is added once the 'Send' button has been pressed.

I want to be able to remove/change the address if necessary.

From the user's perspective: click reply/forward/new email, and the message window opens up with the BCC field filled.

My knowledge of VBA is somewhat limited, so I'd appreciate if you could be specific about where to place the code.

Community
  • 1
  • 1
Hobbes
  • 11
  • 1

1 Answers1

0

This code put in ThisOutlookSession module will fire when you click on the button New Email and when replying to an email. From there it's simple to insert whatever you need in the various fields. You need to restart Outlook or manually call Application_Startup() to have it activated the first time.

Option Explicit

Public WithEvents myInspectors As Outlook.Inspectors
Public WithEvents myExplorer As Outlook.Explorer

Private Sub Application_Startup()
  Set myInspectors = Application.Inspectors
  Set myExplorer = Application.ActiveExplorer
End Sub

Private Sub myInspectors_NewInspector(ByVal Inspector As Inspector)
  If TypeName(Inspector.CurrentItem) = "MailItem" Then
    'MsgBox "new mail"
    Inspector.CurrentItem.BCC = "joe.doe@domain.com"
  End If
End Sub

Private Sub myExplorer_InlineResponse(ByVal Item As Object)
    'MsgBox "reply"
    Item.BCC = "jane.dane@domain.com"
End Sub
  • 2
    To take care of the inline responses, you might also want to handle the Explorer.InlineResponse event. – Dmitry Streblechenko Feb 04 '18 at 18:33
  • Edited my answer accordingly –  Feb 06 '18 at 12:30
  • Keep in mind that Application.ActiveExplorer can be null on startup. – Dmitry Streblechenko Feb 06 '18 at 13:23
  • You can have 0 (e.g. on startup) or more than 1 explorer (if you right click on folder and select "Open in a new Window"). Handling multiple explorers is more pain (you will need to keep a list of open explorers and clean it up when an explorer closes), but in the simplest case when you get 0 explorers, you need to hook up the Explorers.NewExplorer event and set up an event handler fro the Explorer.InlineResponse event. – Dmitry Streblechenko Feb 06 '18 at 15:22